• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP imagecopymerge函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中imagecopymerge函数的典型用法代码示例。如果您正苦于以下问题:PHP imagecopymerge函数的具体用法?PHP imagecopymerge怎么用?PHP imagecopymerge使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了imagecopymerge函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: translucentWatermark

 public static function translucentWatermark($originalImage, $watermark, $saveFile = null, $outputFileTipe = 'jpg')
 {
     $tempFolder = "temp/";
     //$fileRandomValue = 0;
     $cache = $tempFolder . $saveFile . '.' . $outputFileTipe;
     // Load the stamp and the photo to apply the watermark to
     if (strstr($originalImage, '.jpg') !== false) {
         $im = imagecreatefromjpeg($originalImage);
     } elseif (strstr($originalImage, '.png') !== false) {
         $im = imagecreatefrompng($originalImage);
     }
     // First we create our stamp image manually from GD
     $stamp = imagecreatetruecolor(100, 70);
     imagefilledrectangle($stamp, 0, 0, 99, 69, 0xff);
     imagefilledrectangle($stamp, 9, 9, 90, 60, 0xffffff);
     //$im = imagecreatefromjpeg('photo.jpeg');
     imagestring($stamp, 5, 20, 20, 'libGD', 0xff);
     imagestring($stamp, 3, 20, 40, '(c) 2007-9', 0xff);
     // Set the margins for the stamp and get the height/width of the stamp image
     $marge_right = 10;
     $marge_bottom = 10;
     $sx = imagesx($stamp);
     $sy = imagesy($stamp);
     // Merge the stamp onto our photo with an opacity of 50%
     imagecopymerge($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp), 50);
     // Save the image to file and free memory
     imagepng($im, $cache);
     imagedestroy($im);
 }
开发者ID:edarkzero,项目名称:GineObs,代码行数:29,代码来源:WatermarkCreator.php


示例2: overlay

 /**
  * Overlay an image onto the current image.
  *
  * @param  string $image
  * @param  int    $x
  * @param  int    $y
  * @throws Exception
  * @return Gd
  */
 public function overlay($image, $x = 0, $y = 0)
 {
     imagealphablending($this->image->resource(), true);
     // Create an image resource from the overlay image.
     if (stripos($image, '.gif') !== false) {
         $overlay = imagecreatefromgif($image);
     } else {
         if (stripos($image, '.png') !== false) {
             $overlay = imagecreatefrompng($image);
         } else {
             if (stripos($image, '.jp') !== false) {
                 $overlay = imagecreatefromjpeg($image);
             } else {
                 throw new Exception('Error: The overlay image must be either a JPG, GIF or PNG.');
             }
         }
     }
     if ($this->opacity > 0) {
         if ($this->opacity == 100) {
             imagecopy($this->image->resource(), $overlay, $x, $y, 0, 0, imagesx($overlay), imagesy($overlay));
         } else {
             imagecopymerge($this->image->resource(), $overlay, $x, $y, 0, 0, imagesx($overlay), imagesy($overlay), $this->opacity);
         }
     }
     return $this;
 }
开发者ID:Nnadozieomeonu,项目名称:lacecart,代码行数:35,代码来源:Gd.php


示例3: applyFilter

 /**
  * (non-PHPdoc)
  * @see \imagemanipulation\filter\IImageFilter::applyFilter()
  */
 public function applyFilter(ImageResource $resource)
 {
     if ($this->radius === 0) {
         return;
     }
     $source_image = $resource->getResource();
     $source_width = $resource->getX();
     $source_height = $resource->getY();
     $corner_image = imagecreatetruecolor($this->radius, $this->radius);
     $clear_colour = imagecolorallocate($corner_image, 0, 0, 0);
     imagecolortransparent($corner_image, $clear_colour);
     $solid_colour = imagecolorallocate($corner_image, $this->color->getRed(), $this->color->getGreen(), $this->color->getBlue());
     imagefill($corner_image, 0, 0, $solid_colour);
     imagefilledellipse($corner_image, $this->radius, $this->radius, $this->radius * 2, $this->radius * 2, $clear_colour);
     /*
      * render the top-left, bottom-left, bottom-right, top-right corners by rotating and copying the mask
      */
     imagecopymerge($source_image, $corner_image, 0, 0, 0, 0, $this->radius, $this->radius, 100);
     $corner_image = imagerotate($corner_image, 90, 0);
     imagecopymerge($source_image, $corner_image, 0, $source_height - $this->radius, 0, 0, $this->radius, $this->radius, 100);
     $corner_image = imagerotate($corner_image, 90, 0);
     imagecopymerge($source_image, $corner_image, $source_width - $this->radius, $source_height - $this->radius, 0, 0, $this->radius, $this->radius, 100);
     $corner_image = imagerotate($corner_image, 90, 0);
     imagecopymerge($source_image, $corner_image, $source_width - $this->radius, 0, 0, 0, $this->radius, $this->radius, 100);
 }
开发者ID:dreamsxin,项目名称:imagemanipulation,代码行数:29,代码来源:ImageFilterRoundedCorners.php


示例4: applyFilter

 /**
  * Applies the filter to the resource
  *
  * @param ImageResource $aResource
  */
 public function applyFilter(ImageResource $aResource)
 {
     $width = $aResource->getX();
     $height = $aResource->getY();
     $lineRes = imagecreatetruecolor($width, 1);
     $bgc = imagecolorallocatealpha($lineRes, $this->backgroundColor->getRed(), $this->backgroundColor->getGreen(), $this->backgroundColor->getBlue(), $this->backgroundColor->getAlpha());
     // Background color
     imagefilledrectangle($lineRes, 0, 0, $width, 1, $bgc);
     $rotateFilter = new ImageFilterRotate(180, $this->backgroundColor);
     $rotateFilter->applyFilter($aResource);
     $bg = imagecreatetruecolor($width, $this->height);
     imagecopyresampled($bg, $aResource->getResource(), 0, 0, 0, 0, $width, $height, $width, $height);
     $im = $bg;
     $bg = imagecreatetruecolor($width, $this->height);
     for ($x = 0; $x < $width; $x++) {
         imagecopy($bg, $im, $x, 0, $width - $x, 0, 1, $this->height);
     }
     $im = $bg;
     $in = 100 / $this->height;
     for ($i = 0; $i <= $this->height; $i++) {
         imagecopymerge($im, $lineRes, 0, $i, 0, 0, $width, 1, $this->startOpacity);
         if ($this->startOpacity < 100) {
             $this->startOpacity += $in;
         }
     }
     imagecopymerge($im, $lineRes, 0, 0, 0, 0, $width, $this->divLineHeight, 100);
     // Divider
     $aResource->setResource($im);
 }
开发者ID:dreamsxin,项目名称:imagemanipulation,代码行数:34,代码来源:ImageFilterReflection.php


示例5: imagecopymerge_alpha

 public static function imagecopymerge_alpha($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct)
 {
     $cut = imagecreatetruecolor($src_w, $src_h);
     imagecopy($cut, $dst_im, 0, 0, $dst_x, $dst_y, $src_w, $src_h);
     imagecopy($cut, $src_im, 0, 0, $src_x, $src_y, $src_w, $src_h);
     imagecopymerge($dst_im, $cut, $dst_x, $dst_y, 0, 0, $src_w, $src_h, $pct);
 }
开发者ID:vmarchaud,项目名称:42_workspace,代码行数:7,代码来源:Utils.class.php


示例6: ApplyWatermark

 function ApplyWatermark($watermark_path)
 {
     $this->watermark_path = $watermark_path;
     // Determine image size and type
     $size = getimagesize($this->image_path);
     $size_x = $size[0];
     $size_y = $size[1];
     $image_type = $size[2];
     // 1 = GIF, 2 = JPG, 3 = PNG
     // load source image
     $image = $this->ImageCreateFromType($image_type, $this->image_path);
     // Determine watermark size and type
     $wsize = getimagesize($watermark_path);
     $watermark_x = $wsize[0];
     $watermark_y = $wsize[1];
     $watermark_type = $wsize[2];
     // 1 = GIF, 2 = JPG, 3 = PNG
     // load watermark
     $watermark = $this->ImageCreateFromType($watermark_type, $watermark_path);
     // where do we put watermark on the image?
     $dest_x = $size_x - $watermark_x - $this->offset_x;
     $dest_y = $size_y - $watermark_y - $this->offset_y;
     imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_x, $watermark_y, 100);
     $this->image =& $image;
     $this->watermark =& $watermark;
     $this->image_type = $image_type;
 }
开发者ID:biswajit-paul,项目名称:gittest,代码行数:27,代码来源:watermark_image.class.php


示例7: hacknrollify

function hacknrollify($picfilename)
{
    $logofilename = "logo.png";
    $logoPicPath = "logopics/" . $logofilename;
    $originalPicPath = "originalpics/" . $picfilename;
    $editedfilename = "hnr_" . $picfilename;
    $editedPicPath = "editedpics/" . $editedfilename;
    // read the original image from file
    $profilepic = imagecreatefromjpeg($originalPicPath);
    $profilepicWidth = imagesx($profilepic);
    $profilepicHeight = imagesy($profilepic);
    // create the black image overlay
    $blackoverlay = imagecreate($profilepicWidth, $profilepicHeight);
    imagecolorallocate($blackoverlay, 0, 0, 0);
    // then merge the black and profilepic
    imagecopymerge($profilepic, $blackoverlay, 0, 0, 0, 0, $profilepicWidth, $profilepicHeight, 50);
    imagedestroy($blackoverlay);
    // merge the resized logo
    $logo = resizeImage($logoPicPath, $profilepicWidth - 80, 999999);
    imageAlphaBlending($logo, false);
    imageSaveAlpha($logo, true);
    $logoWidth = imagesx($logo);
    $logoHeight = imagesy($logo);
    $verticalOffset = $profilepicHeight / 2 - $logoHeight / 2;
    $horizontalOffset = 40;
    imagecopyresampled($profilepic, $logo, $horizontalOffset, $verticalOffset, 0, 0, $logoWidth, $logoHeight, $logoWidth, $logoHeight);
    $mergeSuccess = imagejpeg($profilepic, $editedPicPath);
    if (!$mergeSuccess) {
        echo "Image merge failed!";
    }
    imagedestroy($profilepic);
    imagedestroy($logo);
    return $editedPicPath;
}
开发者ID:nicholaslum444,项目名称:HacknRollify,代码行数:34,代码来源:lib_hacknrollify.php


示例8: addWatermark

 public function addWatermark($watermark)
 {
     if (!$this->gd) {
         return;
     }
     $newGD = imagecreatetruecolor($this->width, $this->height);
     // Preserves transparency between images
     imagealphablending($newGD, true);
     imagesavealpha($newGD, true);
     imagecopy($newGD, $this->gd, 0, 0, 0, 0, $this->width, $this->height);
     // Load the stamp and the photo to apply the watermark to
     $stamp = imagecreatefrompng($watermark->getFullPath());
     // Set the margins for the stamp and get the height/width of the stamp image
     $sx = imagesx($stamp);
     $sy = imagesy($stamp);
     //bang in the middle
     $dest_x = ceil($this->width / 2);
     $dest_x -= ceil($watermark->width / 2);
     $dest_y = ceil($this->height / 2);
     $dest_y -= ceil($watermark->width / 2);
     //be safe prevent negatives
     if ($dest_x < 0) {
         $dest_x = 0;
     }
     if ($dest_y < 0) {
         $dest_y = 0;
     }
     // SS_Log::log('dest x: '.$dest_x.' dest y: '.$dest_y, SS_Log::ERR);
     // Copy the stamp image onto our photo using the margin offsets and the photo
     // width to calculate positioning of the stamp.
     imagecopymerge($newGD, $stamp, $dest_x, $dest_y, 0, 0, imagesx($stamp), imagesy($stamp), 50);
     $output = clone $this;
     $output->setImageResource($newGD);
     return $output;
 }
开发者ID:robertclarkson,项目名称:silverstripe-watermark,代码行数:35,代码来源:GDWatermarkBackend.php


示例9: make_captcha_img

function make_captcha_img()
{
    global $CaptchaBGs;
    $Length = 6;
    $ImageHeight = 75;
    $ImageWidth = 300;
    $Chars = 'abcdefghjkmprstuvwxyzABCDEFGHJKLMPQRSTUVWXY23456789';
    $CaptchaString = '';
    for ($i = 0; $i < $Length; $i++) {
        $CaptchaString .= $Chars[mt_rand(0, strlen($Chars) - 1)];
    }
    for ($x = 0; $x < $Length; $x++) {
        $FontDisplay[$x]['size'] = mt_rand(24, 32);
        $FontDisplay[$x]['top'] = mt_rand($FontDisplay[$x]['size'] + 5, $ImageHeight - $FontDisplay[$x]['size'] / 2);
        $FontDisplay[$x]['angle'] = mt_rand(-30, 30);
        $FontDisplay[$x]['font'] = get_font();
    }
    $Img = imagecreatetruecolor($ImageWidth, $ImageHeight);
    $BGImg = imagecreatefrompng(SERVER_ROOT . '/captcha/' . $CaptchaBGs[mt_rand(0, count($CaptchaBGs) - 1)]);
    imagecopymerge($Img, $BGImg, 0, 0, 0, 0, 300, 75, 50);
    $ForeColor = imagecolorallocatealpha($Img, 255, 255, 255, 65);
    for ($i = 0; $i < strlen($CaptchaString); $i++) {
        $CharX = $ImageWidth / $Length * ($i + 1) - $ImageWidth / $Length * 0.75;
        imagettftext($Img, $FontDisplay[$i]['size'], $FontDisplay[$i]['angle'], $CharX, $FontDisplay[$i]['top'], $ForeColor, $FontDisplay[$i]['font'], $CaptchaString[$i]);
    }
    header('Content-type: image/png');
    imagepng($Img);
    imagedestroy($Img);
    return $CaptchaString;
}
开发者ID:Kufirc,项目名称:Gazelle,代码行数:30,代码来源:index.php


示例10: process

 /**
  * (non-PHPdoc)
  * @see \Simplify\Thumb\Plugin::process()
  */
 protected function process(\Simplify\Thumb\Processor $thumb, $overlayImage = null, $dst_x = 0, $dst_y = 0, $src_x = 0, $src_y = 0, $src_w = null, $src_h = null, $pct = 0)
 {
     $overlay = \Simplify\Thumb\Functions::load($overlayImage);
     $src_w = is_null($src_w) ? imagesx($overlay) : $src_w;
     $src_h = is_null($src_h) ? imagesy($overlay) : $src_h;
     imagecopymerge($thumb->image, $overlay, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct);
 }
开发者ID:rutkoski,项目名称:simplify-thumb,代码行数:11,代码来源:Merge.php


示例11: water

 public static function water($source, $water, $saveName = null, $pos = 0, $alpha = 80, $quality = 100)
 {
     if (!FileUtil::fileExists($source) || !FileUtil::fileExists($water)) {
         return false;
     }
     $sInfo = self::getImageInfo($source);
     $wInfo = self::getImageInfo($water);
     if ($sInfo["width"] < $wInfo["width"] || $sInfo["height"] < $wInfo["height"]) {
         return false;
     }
     $sCreateFunction = "imagecreatefrom" . $sInfo["type"];
     $sImage = $sCreateFunction($source);
     $wCreateFunction = "imagecreatefrom" . $wInfo["type"];
     $wImage = $wCreateFunction($water);
     imagealphablending($wImage, true);
     list($posX, $posY) = self::getPos($sInfo, $wInfo, $pos);
     if ($wInfo["type"] == "png") {
         imagecopy($sImage, $wImage, $posX, $posY, 0, 0, $wInfo["width"], $wInfo["height"]);
     } else {
         imagealphablending($wImage, true);
         imagecopymerge($sImage, $wImage, $posX, $posY, 0, 0, $wInfo["width"], $wInfo["height"], $alpha);
     }
     $imageFun = "image" . $sInfo["type"];
     if (!$saveName) {
         $saveName = $source;
         @unlink($source);
     }
     if ($sInfo["mime"] == "image/jpeg") {
         $imageFun($sImage, $saveName, $quality);
     } else {
         $imageFun($sImage, $saveName);
     }
     imagedestroy($sImage);
     return true;
 }
开发者ID:AxelPanda,项目名称:ibos,代码行数:35,代码来源:ImageUtil.php


示例12: drawCollage

 /**
  * Method draws a collage from friends avatars.
  *
  * @param $x
  * @param $y
  * @return resource
  * @throws \Exception
  */
 public function drawCollage($x, $y)
 {
     $username = 'k_riby';
     $friends = $this->getFriendsList($username);
     $posX = 0;
     $posY = 0;
     if (!isset($x) && !isset($y)) {
         throw new \Exception("height and width must be set!");
     }
     $collage = imagecreatetruecolor($x, $y);
     while ($posY <= $y) {
         foreach ($friends['users'] as $user) {
             $image = imagecreatefromstring(file_get_contents($user['profile_image_url']));
             imagecopymerge($collage, $image, $posX, $posY, 5, 5, 50, 50, 100);
             $posX += 50;
             if ($posX >= $x) {
                 $posY += 50;
                 $posX = 0;
             }
             if ($posX >= $x && $posY >= $y) {
                 break;
             }
         }
     }
     return $collage;
 }
开发者ID:kriby,项目名称:twitter_collage,代码行数:34,代码来源:Collage.php


示例13: water

 public static function water($dst, $water, $save = NULL, $pos = 2, $alpha = 50)
 {
     //先保证两个图片存在
     if (!file_exists($dst) || !file_exists($water)) {
         return false;
     }
     //首先保证水印不能比待操作图片大
     $dinfo = self::imageInfo($dst);
     $winfo = self::imageInfo($water);
     if ($winfo['height'] > $dinfo['height'] || $winfo['width'] > $dinfo['width']) {
         return false;
     }
     //两张图,读到画布上,但是图片可能是png,可能是jpeg,用什么函数读
     $dfunc = 'imagecreatefrom' . $dinfo['ext'];
     $wfunc = 'imagecreatefrom' . $winfo['ext'];
     if (!function_exists($dfunc) || !function_exists($wfunc)) {
         return false;
     }
     //动态加载函数来创建画布
     $dim = $dfunc($dst);
     //创建待操作画布
     $wim = $wfunc($water);
     // 创建水印画布
     //根据水印的位置,计算粘贴的坐标
     switch ($pos) {
         case 0:
             //左上角
             $posx = 0;
             $posy = 0;
             break;
         case 1:
             //右上角
             $posx = $dinfo['width'] - $winfo['width'];
             $posy = 0;
             break;
         case 3:
             //左下角
             $posx = 0;
             $posy = $dinfo['height'] - $winfo['height'];
             break;
         default:
             //右下角
             $posx = $dinfo['width'] - $winfo['width'];
             $posy = $dinfo['height'] - $winfo['height'];
             break;
     }
     //加水印
     imagecopymerge($dim, $wim, $posx, $posy, 0, 0, $winfo['width'], $winfo['height'], $alpha);
     //保存
     if (!$save) {
         $save = $dst;
         unlink($dst);
         //删除原图
     }
     $createfunc = 'image' . $dinfo['ext'];
     $createfunc($dim, $save);
     imagedestroy($dim);
     imagedestroy($wim);
     return true;
 }
开发者ID:kison30,项目名称:new,代码行数:60,代码来源:ImageTool.class.php


示例14: create_watermark

function create_watermark($source_file_path, $output_file_path)
{
    list($source_width, $source_height, $source_type) = getimagesize($source_file_path);
    if ($source_type === NULL) {
        return false;
    }
    switch ($source_type) {
        case IMAGETYPE_GIF:
            $source_gd_image = imagecreatefromgif($source_file_path);
            break;
        case IMAGETYPE_JPEG:
            $source_gd_image = imagecreatefromjpeg($source_file_path);
            break;
        case IMAGETYPE_PNG:
            $source_gd_image = imagecreatefrompng($source_file_path);
            break;
        default:
            return false;
    }
    $overlay_gd_image = imagecreatefrompng(WATERMARK_OVERLAY_IMAGE);
    $overlay_width = imagesx($overlay_gd_image);
    $overlay_height = imagesy($overlay_gd_image);
    imagecopymerge($source_gd_image, $overlay_gd_image, $source_width - $overlay_width, $source_height - $overlay_height, 0, 0, $overlay_width, $overlay_height, WATERMARK_OVERLAY_OPACITY);
    imagejpeg($source_gd_image, $output_file_path, WATERMARK_OUTPUT_QUALITY);
    imagedestroy($source_gd_image);
    imagedestroy($overlay_gd_image);
    //unlink($source_file_path);
}
开发者ID:biswajit-paul,项目名称:gittest,代码行数:28,代码来源:watermark-image.php


示例15: by_lines

 function by_lines($image, &$size_x, &$size_y)
 {
     $lines = array();
     $size_x = imagesx($image->get_handle());
     $size_y = imagesy($image->get_handle());
     $dest_img = imagecreatetruecolor($size_x, $size_y);
     imagecopymerge($dest_img, $image->get_handle(), 0, 0, 0, 0, $size_x, $size_y, 100);
     // initialize line length counter
     $ctr = 0;
     for ($y = 0; $y < $size_y; $y++) {
         $line = "";
         for ($x = 0; $x < $size_x; $x++) {
             // Save image pixel to the stream data
             $rgb = ImageColorAt($dest_img, $x, $y);
             $r = $rgb >> 16 & 0xff;
             $g = $rgb >> 8 & 0xff;
             $b = $rgb & 0xff;
             $line .= sprintf("%02X%02X%02X", min(max($r, 0), 255), min(max($g, 0), 255), min(max($b, 0), 255));
             // Increate the line length counter; check if stream line needs to be terminated
             $ctr += 6;
             if ($ctr > MAX_LINE_LENGTH) {
                 $line .= "\n";
                 $ctr = 0;
             }
         }
         $lines[] = $line;
     }
     return $lines;
 }
开发者ID:isantiago,项目名称:foswiki,代码行数:29,代码来源:ps.l2.image.encoder.stream.inc.php


示例16: background

 function background()
 {
     $im = imagecreatetruecolor($this->width, $this->height);
     $bgs = array();
     if ($this->style & 8 && function_exists('imagecreatefromjpeg') && function_exists('imagecopymerge')) {
         if ($fp = @opendir($GLOBALS['imgdir'] . '/ck/bg/')) {
             while ($flie = @readdir($fp)) {
                 if (preg_match('/\\.jpg$/i', $flie)) {
                     $bgs[] = $GLOBALS['imgdir'] . '/ck/bg/' . $flie;
                 }
             }
             @closedir($fp);
         }
     }
     if ($bgs) {
         $imbg = imagecreatefromjpeg($bgs[array_rand($bgs)]);
         imagecopymerge($im, $imbg, 0, 0, mt_rand(0, 200 - $this->width), mt_rand(0, 80 - $this->height), $this->width, $this->height, 100);
         imagedestroy($imbg);
     } else {
         $c = array();
         for ($i = 0; $i < 3; $i++) {
             $c[$i] = mt_rand(200, 255);
             $step[$i] = (mt_rand(100, 150) - $c[$i]) / $this->width;
         }
         for ($i = 0; $i < $this->width; $i++) {
             imageline($im, $i, 0, $i, $this->height, imagecolorallocate($im, $c[0], $c[1], $c[2]));
             $c[0] += $step[0];
             $c[1] += $step[1];
             $c[2] += $step[2];
         }
     }
     return $im;
 }
开发者ID:adi00,项目名称:wumaproject,代码行数:33,代码来源:ck.php


示例17: reflect

 public function reflect()
 {
     $transparency_step = (100 - $this->transparency) / $this->gradient_height;
     $background = imagecreatetruecolor($this->imgWidth, $this->gradient_height + $this->imgHeight);
     $gdGradientColor = ImageColorAllocate($background, 255, 255, 255);
     $newImage = imagecreatetruecolor($this->imgWidth, $this->imgHeight);
     for ($x = 0; $x < $this->imgWidth; $x++) {
         for ($y = 0; $y < $this->imgHeight; $y++) {
             imagecopy($newImage, $this->img, $x, $this->imgHeight - $y - 1, $x, $y, 1, 1);
         }
     }
     imagecopymerge($background, $newImage, 0, $this->imgHeight, 0, 0, $this->imgWidth, $this->imgHeight, 100);
     imagecopymerge($background, $this->img, 0, 0, 0, 0, $this->imgWidth, $this->imgHeight, 100);
     $gradient_line = imagecreatetruecolor($this->imgWidth, 1);
     //voir si on garde ça et la suite
     // Next we draw a GD line into our gradient_line
     imageline($gradient_line, 0, 0, $this->imgWidth, 0, $gdGradientColor);
     for ($i = $this->imgHeight; $i < $this->gradient_height + $this->imgHeight; $i++) {
         imagecopymerge($background, $gradient_line, 0, $i, 0, 0, $this->imgWidth, 1, $this->transparency);
         if ($this->transparency != 100) {
             $this->transparency += $transparency_step;
         }
     }
     $this->img = $background;
 }
开发者ID:nchourrout,项目名称:GD-Mirror,代码行数:25,代码来源:mirror_effect.class.php


示例18: addWaterMark

 /**
  * 图片打水印
  *
  * @param string $sourceImage 源图片
  * @param string $waterMarkImage 水印
  * @param null|string $saveName 保存路径,默认为覆盖原图
  * @param int $alpha 水印透明度
  * @param null $positionW 水印位置 相对原图横坐标
  * @param null $positionH 水印位置 相对原图纵坐标
  * @param int $quality 生成的图片的质量 jpeg有效
  *
  * @return mixed
  */
 public static function addWaterMark($sourceImage, $waterMarkImage, $saveName = null, $alpha = 80, $positionW = null, $positionH = null, $quality = 100)
 {
     if (!is_file($sourceImage) || !is_file($waterMarkImage)) {
         return false;
     }
     //获取图片信息
     $sourceImageInfo = self::getImageInfo($sourceImage);
     $waterMarkImageInfo = self::getImageInfo($waterMarkImage);
     if ($sourceImageInfo['width'] < $waterMarkImageInfo['width'] || $sourceImageInfo['height'] < $waterMarkImageInfo['height'] || $sourceImageInfo['ext'] == 'bmp' || $waterMarkImageInfo['bmp']) {
         return false;
     }
     //创建图像
     $sourceImageCreateFunc = "imagecreatefrom{$sourceImageInfo['ext']}";
     $sourceCreateImage = $sourceImageCreateFunc($sourceImage);
     $waterMarkImageCreateFunc = "imagecreatefrom{$waterMarkImageInfo['ext']}";
     $waterMarkCreateImage = $waterMarkImageCreateFunc($waterMarkImage);
     //设置混色模式
     imagealphablending($waterMarkImage, true);
     $posX = is_null($positionW) ? $sourceImageInfo['width'] - $waterMarkImageInfo['width'] : $sourceImageInfo['width'] - $positionW;
     $posY = is_null($positionH) ? $sourceImageInfo['height'] - $waterMarkImageInfo['height'] : $sourceImageInfo['height'] - $positionH;
     //生成混合图像
     imagecopymerge($sourceCreateImage, $waterMarkCreateImage, $posX, $posY, 0, 0, $waterMarkImageInfo['width'], $waterMarkImageInfo['height'], $alpha);
     //生成处理后的图像
     if (is_null($saveName)) {
         $saveName = $sourceImage;
         @unlink($sourceImage);
     }
     self::output($sourceCreateImage, $sourceImageInfo['ext'], $saveName, $quality);
     return true;
 }
开发者ID:linhecheng,项目名称:cmlphp,代码行数:43,代码来源:Image.php


示例19: download

 function download()
 {
     global $STYLE;
     if (!isset($_GET["id"])) {
         throw new Exception("No 'id' or 'name' param provided.");
     }
     /* call get_document.php to get the image */
     ob_start();
     include 'get_document.php';
     $data = ob_get_contents();
     ob_end_clean();
     if (ENABLE_IMAGE_WATERMARKING) {
         /* create a gd object from data */
         $im = @imagecreatefromstring($data);
         if (!$im) {
             throw new Exception("Ressource is not an image!");
         } else {
             /* Watermark settings - Implement a company specifil logo here later. */
             $transition = 85;
             $watermarkfile = imagecreatefrompng(PATH_PUBLIC . 'styles/' . $STYLE . '/images/logo_bdz.png');
             //TODO: Change the path here!
             $waternarkpic_width = imagesx($watermarkfile);
             $waternarkpic_height = imagesy($watermarkfile);
             $watermarkdest_x = 15;
             $watermarkdest_y = 15;
             imagecopymerge($im, $watermarkfile, $watermarkdest_x, $watermarkdest_y, 0, 0, $waternarkpic_width, $waternarkpic_height, $transition);
             imagejpeg($im);
         }
     } else {
         echo $data;
     }
 }
开发者ID:rolwi,项目名称:koala,代码行数:32,代码来源:watermark_downloader.class.php


示例20: execute

 /**
  * {@inheritdoc}
  */
 protected function execute(array $arguments)
 {
     if ($arguments['opacity'] === 100) {
         // Use imagecopy() if watermark opacity is 100%.
         return imagecopy($this->getToolkit()->getResource(), $arguments['watermark_image']->getToolkit()->getResource(), $arguments['x_offset'], $arguments['y_offset'], 0, 0, $arguments['watermark_image']->getToolkit()->getWidth(), $arguments['watermark_image']->getToolkit()->getHeight());
     } else {
         // If opacity is below 100%, use the approach described in
         // http://php.net/manual/it/function.imagecopymerge.php#92787
         // to preserve watermark alpha.
         // Create a cut resource.
         // @todo when #2583041 is committed, add a check for memory
         // availability before crating the resource.
         $cut = imagecreatetruecolor($arguments['watermark_image']->getToolkit()->getWidth(), $arguments['watermark_image']->getToolkit()->getHeight());
         if (!is_resource($cut)) {
             return FALSE;
         }
         // Copy relevant section from destination image to the cut resource.
         $success = imagecopy($cut, $this->getToolkit()->getResource(), 0, 0, $arguments['x_offset'], $arguments['y_offset'], $arguments['watermark_image']->getToolkit()->getWidth(), $arguments['watermark_image']->getToolkit()->getHeight());
         if (!$success) {
             imagedestroy($cut);
             return FALSE;
         }
         // Copy relevant section from watermark image to the cut resource.
         $success = imagecopy($cut, $arguments['watermark_image']->getToolkit()->getResource(), 0, 0, 0, 0, $arguments['watermark_image']->getToolkit()->getWidth(), $arguments['watermark_image']->getToolkit()->getHeight());
         if (!$success) {
             imagedestroy($cut);
             return FALSE;
         }
         // Insert cut resource to destination image.
         $success = imagecopymerge($this->getToolkit()->getResource(), $cut, $arguments['x_offset'], $arguments['y_offset'], 0, 0, $arguments['watermark_image']->getToolkit()->getWidth(), $arguments['watermark_image']->getToolkit()->getHeight(), $arguments['opacity']);
         imagedestroy($cut);
         return $success;
     }
 }
开发者ID:andrewl,项目名称:andrewlnet,代码行数:37,代码来源:Watermark.php



注:本文中的imagecopymerge函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP imagecopymergegray函数代码示例发布时间:2022-05-15
下一篇:
PHP imagecopy函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap