當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Imagick::compositeImage方法代碼示例

本文整理匯總了PHP中Imagick::compositeImage方法的典型用法代碼示例。如果您正苦於以下問題:PHP Imagick::compositeImage方法的具體用法?PHP Imagick::compositeImage怎麽用?PHP Imagick::compositeImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Imagick的用法示例。


在下文中一共展示了Imagick::compositeImage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: fx

 /**
  *
  * @param mixed color
  * @param float opacity
  */
 public function fx($color = 'black', $opacity = 0.3)
 {
     $this->im->setImageFormat('png');
     $reflection = $this->im->clone();
     $reflection->flipImage();
     $gradient = new Imagick();
     $gradient->newPseudoImage($reflection->getImageWidth(), $reflection->getImageHeight(), "gradient:transparent-{$color}");
     $reflection->compositeImage($gradient, imagick::COMPOSITE_OVER, 0, 0);
     $reflection->setImageOpacity($opacity);
     $canvas = new Imagick();
     $canvas->newImage($this->im->getImageWidth(), $this->im->getImageHeight() * 2, $color, "png");
     $canvas->compositeImage($this->im, imagick::COMPOSITE_OVER, 0, 0);
     $canvas->compositeImage($reflection, imagick::COMPOSITE_OVER, 0, $this->im->getImageHeight());
     return $canvas;
 }
開發者ID:raspi,項目名稱:iMagickFx,代碼行數:20,代碼來源:reflection.php

示例2: multiply

function multiply($firstPicture, $twoPicture, $x, $y)
{
    $img = new Imagick($firstPicture);
    $img->thumbnailImage(140, 140);
    $shadow = $img->clone();
    $shadow->setImageBackgroundColor(new ImagickPixel('black'));
    //color shadow
    $shadow->shadowImage(80, 3, 5, 5);
    //create shadow
    $shadow->compositeImage($img, Imagick::COMPOSITE_OVER, 0, 0);
    header("Content-Type: image/jpeg");
    $img2 = new Imagick($twoPicture);
    $img2->compositeImage($shadow, $shadow->getImageCompose(), $x, $y);
    echo $img2;
}
開發者ID:Arxemond777,項目名稱:Multiply,代碼行數:15,代碼來源:indexMultiply.php

示例3: execute

 /**
  * Reduces colors of a given image
  *
  * @param  Intervention\Image\Image $image
  * @return boolean
  */
 public function execute($image)
 {
     $count = $this->argument(0)->value();
     $matte = $this->argument(1)->value();
     // get current image size
     $size = $image->getSize();
     // build 2 color alpha mask from original alpha
     $alpha = clone $image->getCore();
     $alpha->separateImageChannel(\Imagick::CHANNEL_ALPHA);
     $alpha->transparentPaintImage('#ffffff', 0, 0, false);
     $alpha->separateImageChannel(\Imagick::CHANNEL_ALPHA);
     $alpha->negateImage(false);
     if ($matte) {
         // get matte color
         $mattecolor = $image->getDriver()->parseColor($matte)->getPixel();
         // create matte image
         $canvas = new \Imagick();
         $canvas->newImage($size->width, $size->height, $mattecolor, 'png');
         // lower colors of original and copy to matte
         $image->getCore()->quantizeImage($count, \Imagick::COLORSPACE_RGB, 0, false, false);
         $canvas->compositeImage($image->getCore(), \Imagick::COMPOSITE_DEFAULT, 0, 0);
         // copy new alpha to canvas
         $canvas->compositeImage($alpha, \Imagick::COMPOSITE_COPYOPACITY, 0, 0);
         // replace core
         $image->setCore($canvas);
     } else {
         $image->getCore()->quantizeImage($count, \Imagick::COLORSPACE_RGB, 0, false, false);
         $image->getCore()->compositeImage($alpha, \Imagick::COMPOSITE_COPYOPACITY, 0, 0);
     }
     return true;
 }
開發者ID:RHoKAustralia,項目名稱:onaroll21_backend,代碼行數:37,代碼來源:LimitColorsCommand.php

示例4: watermarkPrint_imagick

 private function watermarkPrint_imagick($src, $watermark, $dest_x, $dest_y, $quality, $transparency, $watermarkImgInfo)
 {
     try {
         // Open the original image
         $img = new Imagick($src);
         // Open the watermark
         $watermark = new Imagick($watermark);
         // Set transparency
         if (strtoupper($watermark->getImageFormat()) !== 'PNG') {
             $watermark->setImageOpacity($transparency / 100);
         }
         // Overlay the watermark on the original image
         $img->compositeImage($watermark, imagick::COMPOSITE_OVER, $dest_x, $dest_y);
         // Set quality
         if (strtoupper($img->getImageFormat()) === 'JPEG') {
             $img->setImageCompression(imagick::COMPRESSION_JPEG);
             $img->setCompressionQuality($quality);
         }
         $result = $img->writeImage($src);
         $img->clear();
         $img->destroy();
         $watermark->clear();
         $watermark->destroy();
         return $result ? true : false;
     } catch (Exception $e) {
         return false;
     }
 }
開發者ID:devsnippet,項目名稱:yona-cms,代碼行數:28,代碼來源:plugin.php

示例5: apply

 /**
  * Applies the effect.
  */
 public function apply()
 {
     if (!method_exists($this->_image->imagick, 'polaroidImage') || !method_exists($this->_image->imagick, 'trimImage')) {
         throw new Horde_Image_Exception('Your version of Imagick is not compiled against a recent enough ImageMagick library to use the PolaroidImage effect.');
     }
     try {
         // This determines the color of the underlying shadow.
         $this->_image->imagick->setImageBackgroundColor(new ImagickPixel($this->_params['shadowcolor']));
         $this->_image->imagick->polaroidImage(new ImagickDraw(), $this->_params['angle']);
         // We need to create a new image to composite the polaroid over.
         // (yes, even if it's a transparent background evidently)
         $size = $this->_image->getDimensions();
         $imk = new Imagick();
         $imk->newImage($size['width'], $size['height'], $this->_params['background']);
         $imk->setImageFormat($this->_image->getType());
         $result = $imk->compositeImage($this->_image->imagick, Imagick::COMPOSITE_OVER, 0, 0);
         $this->_image->imagick->clear();
         $this->_image->imagick->addImage($imk);
     } catch (ImagickPixelException $e) {
         throw new Horde_Image_Exception($e);
     } catch (ImagickDrawException $e) {
         throw new Horde_Image_Exception($e);
     } catch (ImagickException $e) {
         throw new Horde_Image_Exception($e);
     }
     $imk->destroy();
 }
開發者ID:horde,項目名稱:horde,代碼行數:30,代碼來源:PolaroidImage.php

示例6: Imagick

 function apply_mask($image_src_path, $mask_path, $image_dest_path)
 {
     $src = new Imagick($image_src_path);
     $mask = new Imagick($mask_path);
     $src->compositeImage($mask, Imagick::COMPOSITE_DEFAULT, 0, 0);
     $src->writeImage($image_dest_path);
 }
開發者ID:katekligman,項目名稱:fastcheck,代碼行數:7,代碼來源:imagecompare.class.php

示例7: Imagick

 function page_testfonts()
 {
     //load background
     $im = new Imagick();
     $im->newimage(800, 10000, 'lightgray');
     $y = 10;
     $i = 1;
     foreach ($im->queryFonts() as $font) {
         $insert_image = new Imagick();
         $insert_image->newImage(600, 30, 'whitesmoke');
         $insert_image->setImageFormat("png");
         $draw = new ImagickDraw();
         $draw->setFont($font);
         $draw->setFontSize(25);
         $draw->setFillColor(new ImagickPixel('black'));
         $draw->setgravity(imagick::GRAVITY_NORTH);
         $insert_image->annotateImage($draw, 0, 0, 0, $i . '.' . $font);
         $im->compositeImage($insert_image, $insert_image->getImageCompose(), 100, $y);
         $y += 30;
         $i++;
     }
     $im->setImageFormat('jpg');
     header('Content-Type: image/jpg');
     echo $im;
 }
開發者ID:xepan,項目名稱:commerce,代碼行數:25,代碼來源:fonts.php

示例8: watermark

 /**
  * {@inheritdoc}
  */
 public function watermark($file, $position = Image::WATERMARK_TOP_LEFT, $opacity = 100)
 {
     $watermark = new Imagick($file);
     $watermarkW = $watermark->getImageWidth();
     $watermarkH = $watermark->getImageHeight();
     if ($opacity < 100) {
         $watermark->evaluateImage(Imagick::EVALUATE_MULTIPLY, $opacity / 100, Imagick::CHANNEL_ALPHA);
     }
     // Position the watermark.
     switch ($position) {
         case Image::WATERMARK_TOP_RIGHT:
             $x = $this->image->getImageWidth() - $watermarkW;
             $y = 0;
             break;
         case Image::WATERMARK_BOTTOM_LEFT:
             $x = 0;
             $y = $this->image->getImageHeight() - $watermarkH;
             break;
         case Image::WATERMARK_BOTTOM_RIGHT:
             $x = $this->image->getImageWidth() - $watermarkW;
             $y = $this->image->getImageHeight() - $watermarkH;
             break;
         case Image::WATERMARK_CENTER:
             $x = $this->image->getImageWidth() / 2 - $watermarkW / 2;
             $y = $this->image->getImageHeight() / 2 - $watermarkH / 2;
             break;
         default:
             $x = 0;
             $y = 0;
     }
     $this->image->compositeImage($watermark, Imagick::COMPOSITE_OVER, $x, $y);
     $watermark->destroy();
 }
開發者ID:muhammetardayildiz,項目名稱:framework,代碼行數:36,代碼來源:ImageMagick.php

示例9: addWatermark

 public function addWatermark($image_path)
 {
     try {
         // Open the original image
         $image = new \Imagick();
         $is_success = $image->readImage($image_path);
         if ($is_success === FALSE) {
             throw new WatermarkException("Cannot read uploaded image");
         }
         $watermark = new \Imagick();
         $is_success = $watermark->readImage($this->_WATERMARK_IMAGE_PATH);
         if ($is_success === FALSE) {
             throw new WatermarkException("Cannot read uploaded image");
         }
         $image_width = $image->getImageWidth();
         $image_height = $image->getImageHeight();
         $watermark_width = $watermark->getImageWidth();
         $watermark_height = $watermark->getImageHeight();
         $watermark_pos_x = $image_width - $watermark_width - 20;
         $watermark_pos_y = 20;
         // Overlay the watermark on the original image
         $is_success = $image->compositeImage($watermark, \imagick::COMPOSITE_OVER, $watermark_pos_x, $watermark_pos_y);
         if ($is_success === FALSE) {
             throw new WatermarkException("Cannot save image after watermarked");
         }
         //Write the image
         $image->writeImage($image_path);
     } catch (ImagickException $e) {
         error_log($e->getMessage());
         throw new WatermarkException($e->getMessage(), $e->getCode(), $e);
     }
 }
開發者ID:viggi2004,項目名稱:datacollector-backend,代碼行數:32,代碼來源:Watermark.php

示例10: save

 protected function save($path)
 {
     $pathinfo = pathinfo($path);
     if (!file_exists($pathinfo['dirname'])) {
         mkdir($pathinfo['dirname'], 0777, true);
     }
     try {
         $image = new \Imagick($this->source);
         $image->thumbnailImage($this->width, $this->height, true);
         if ($this->color) {
             $thumb = $image;
             $image = new \Imagick();
             $image->newImage($this->width, $this->height, $this->color, $pathinfo['extension']);
             $size = $thumb->getImageGeometry();
             $x = ($this->width - $size['width']) / 2;
             $y = ($this->height - $size['height']) / 2;
             $image->compositeImage($thumb, \imagick::COMPOSITE_OVER, $x, $y);
             $thumb->destroy();
         }
         $image->writeImage($path);
         $image->destroy();
     } catch (\Exception $e) {
     }
     return $this;
 }
開發者ID:disdain,項目名稱:thumb,代碼行數:25,代碼來源:Thumb.php

示例11: resizeTo

 public function resizeTo($width, $height)
 {
     if (osc_use_imagick()) {
         $bg = new Imagick();
         $bg->newImage($width, $height, 'white');
         $this->im->thumbnailImage($width, $height, true);
         $geometry = $this->im->getImageGeometry();
         $x = ($width - $geometry['width']) / 2;
         $y = ($height - $geometry['height']) / 2;
         $bg->compositeImage($this->im, imagick::COMPOSITE_OVER, $x, $y);
         $this->im = $bg;
     } else {
         $w = imagesx($this->im);
         $h = imagesy($this->im);
         if ($w / $h >= $width / $height) {
             //$newW = $width;
             $newW = $w > $width ? $width : $w;
             $newH = $h * ($newW / $w);
         } else {
             //$newH = $height;
             $newH = $h > $height ? $height : $h;
             $newW = $w * ($newH / $h);
         }
         $newIm = imagecreatetruecolor($width, $height);
         //$newW, $newH);
         imagealphablending($newIm, false);
         $colorTransparent = imagecolorallocatealpha($newIm, 255, 255, 255, 127);
         imagefill($newIm, 0, 0, $colorTransparent);
         imagesavealpha($newIm, true);
         imagecopyresampled($newIm, $this->im, ($width - $newW) / 2, ($height - $newH) / 2, 0, 0, $newW, $newH, $w, $h);
         imagedestroy($this->im);
         $this->im = $newIm;
     }
     return $this;
 }
開發者ID:jmcclenon,項目名稱:Osclass,代碼行數:35,代碼來源:ImageResizer.php

示例12: softThumb

 public function softThumb($width, $height, $path, $bg = 'transparent')
 {
     if ($this->originImage) {
         echo "\nWrite image to `{$path}`\n";
         $resizeParams = $this->getSizes($width, $height);
         $overlay = clone $this->originImage;
         $overlay->scaleImage($resizeParams['width'], $resizeParams['height']);
         $overlayGeo = $overlay->getImageGeometry();
         if ($overlayGeo['width'] > $overlayGeo['height']) {
             $resizeParams['top'] = ($height - $overlayGeo['height']) / 2;
             $resizeParams['left'] = 0;
         } else {
             $resizeParams['top'] = 0;
             $resizeParams['left'] = ($width - $overlayGeo['width']) / 2;
         }
         $thumb = new \Imagick();
         $thumb->newImage($width, $height, $bg);
         $thumb->setImageFormat("png");
         $thumb->setCompression(\Imagick::COMPRESSION_ZIP);
         $thumb->setImageCompressionQuality(0);
         $thumb->compositeImage($overlay, \Imagick::COMPOSITE_DEFAULT, $resizeParams['left'], $resizeParams['top']);
         $thumb->writeImageFile(fopen($path, "wb"));
         $thumb->destroy();
     } else {
         throw new \Exception("As first You must load image", 404);
     }
 }
開發者ID:iryska,項目名稱:nagginua,代碼行數:27,代碼來源:ImageEditor.php

示例13: overlay

 public function overlay($layer, $x = 0, $y = 0)
 {
     $layerCs = $layer->image->getImageColorspace();
     $layer->image->setImageColorspace($this->image->getImageColorspace());
     $this->image->compositeImage($layer->image(), $this->compositionMode, $x, $y);
     $layer->image->setImageColorspace($layerCs);
     return $this;
 }
開發者ID:phpixie,項目名稱:image,代碼行數:8,代碼來源:Resource.php

示例14: renderFontEffect

function renderFontEffect()
{
    $canvas = new \Imagick();
    $canvas->newPseudoImage(500, 300, "canvas:none");
    $canvas->setImageFormat('png');
    $shadow = clone $canvas;
    $text = clone $canvas;
    drawText($text);
    drawText($shadow, true);
    $edge = getSilhouette($text);
    $kernel = \ImagickKernel::fromBuiltIn(\Imagick::KERNEL_OCTAGON, "2");
    $edge->morphology(\Imagick::MORPHOLOGY_EDGE_IN, 1, $kernel);
    $edge->compositeImage($text, \Imagick::COMPOSITE_ATOP, 0, 0);
    $canvas->compositeImage($shadow, \Imagick::COMPOSITE_COPY, 0, 0);
    $canvas->compositeImage($text, \Imagick::COMPOSITE_ATOP, 0, 0);
    header("Content-Type: image/png");
    echo $canvas->getImageBlob();
}
開發者ID:atawsports2,項目名稱:Imagick-demos,代碼行數:18,代碼來源:fontEffect.php

示例15: inscribeImageIntoCanvas

 private function inscribeImageIntoCanvas(\Imagick $image) : \Imagick
 {
     $dimensions = $image->getImageGeometry();
     $x = (int) round(($this->width - $dimensions['width']) / 2);
     $y = (int) round(($this->height - $dimensions['height']) / 2);
     $canvas = new \Imagick();
     $canvas->newImage($this->width, $this->height, $this->backgroundColor, $image->getImageFormat());
     $canvas->compositeImage($image, \Imagick::COMPOSITE_OVER, $x, $y);
     return $canvas;
 }
開發者ID:lizards-and-pumpkins,項目名稱:lib-image-processing-imagick,代碼行數:10,代碼來源:ImageMagickInscribeStrategy.php


注:本文中的Imagick::compositeImage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。