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


PHP Imagick::setImageOpacity方法代碼示例

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


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

示例1: 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

示例2: _watermark

 protected function _watermark($filename, $position, $padding = 5)
 {
     extract(parent::_watermark($filename, $position, $padding));
     $wmimage = new \Imagick();
     $wmimage->readImage($filename);
     $wmimage->setImageOpacity($this->config['watermark_alpha'] / 100);
     $this->imagick->compositeImage($wmimage, \Imagick::COMPOSITE_DEFAULT, $x, $y);
 }
開發者ID:469306621,項目名稱:Languages,代碼行數:8,代碼來源:imagick.php

示例3: overlay

 /**
  * Overlay an image onto the current image.
  *
  * @param  string $image
  * @param  int    $x
  * @param  int    $y
  * @return Imagick
  */
 public function overlay($image, $x = 0, $y = 0)
 {
     $overlayImage = new \Imagick($image);
     if ($this->opacity < 1) {
         $overlayImage->setImageOpacity($this->opacity);
     }
     $this->image->resource()->compositeImage($overlayImage, $this->overlay, $x, $y);
     return $this;
 }
開發者ID:popphp,項目名稱:pop-image,代碼行數:17,代碼來源:Imagick.php

示例4: watermark

 public function watermark($waterImage, $pos = 5, $Opacity = 0.2)
 {
     $water = new \Imagick($waterImage);
     $water->setImageOpacity($Opacity);
     $dw = new \ImagickDraw();
     $dw->setGravity($pos);
     $dw->composite($water->getImageCompose(), 0, 0, 50, 0, $water);
     $this->_handle->drawImage($dw);
     $water->destroy();
     $dw->destroy();
 }
開發者ID:locphp,項目名稱:rsf,代碼行數:11,代碼來源:HandleImagek.php

示例5: crop

 /**
  * Crops Image.
  *
  * @since 3.5.0
  * @access public
  *
  * @param string|int $src The source file or Attachment ID.
  * @param int $src_x The start x position to crop from.
  * @param int $src_y The start y position to crop from.
  * @param int $src_w The width to crop.
  * @param int $src_h The height to crop.
  * @param int $dst_w Optional. The destination width.
  * @param int $dst_h Optional. The destination height.
  * @param boolean $src_abs Optional. If the source crop points are absolute.
  * @return boolean|WP_Error
  */
 public function crop($src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false)
 {
     $ar = $src_w / $src_h;
     $dst_ar = $dst_w / $dst_h;
     if (isset($_GET['pte-fit-crop-color']) && abs($ar - $dst_ar) > 0.01) {
         PteLogger::debug(sprintf("IMAGICK - AR: '%f'\tOAR: '%f'", $ar, $dst_ar));
         // Crop the image to the correct aspect ratio...
         if ($dst_ar > $ar) {
             // constrain to the dst_h
             $tmp_dst_h = $dst_h;
             $tmp_dst_w = $dst_h * $ar;
             $tmp_dst_y = 0;
             $tmp_dst_x = $dst_w / 2 - $tmp_dst_w / 2;
         } else {
             $tmp_dst_w = $dst_w;
             $tmp_dst_h = $dst_w / $ar;
             $tmp_dst_x = 0;
             $tmp_dst_y = $dst_h / 2 - $tmp_dst_h / 2;
         }
         //$color = this::getImagickPixel( $_GET['pte-fit-crop-color'] );
         if (preg_match("/^#[a-fA-F0-9]{6}\$/", $_GET['pte-fit-crop-color'])) {
             $color = new ImagickPixel($_GET['pte-fit-crop-color']);
         }
         //else {
         //    PteLogger::debug( "setting transparent/white" );
         //    $color = new ImagickPixel( 'white' );
         //    //$color->setColorValue( Imagick::COLOR_ALPHA, 0 );
         //}
         try {
             // crop the original image
             $this->image->cropImage($src_w, $src_h, $src_x, $src_y);
             $this->image->scaleImage($tmp_dst_w, $tmp_dst_h);
             // Create a new image and then compose the old one onto it.
             $img = new Imagick();
             $img->newImage($dst_w, $dst_h, isset($color) ? $color : 'white');
             $img->setImageFormat($this->image->getImageFormat());
             if (!isset($color)) {
                 $img->setImageOpacity(0.0);
             }
             $img->compositeImage($this->image, Imagick::COMPOSITE_DEFAULT, $tmp_dst_x, $tmp_dst_y);
             $img->flattenImages();
             $this->image = $img;
         } catch (Exception $e) {
             return new WP_Error('image_crop_error', __('Image crop failed.'), $this->file);
         }
         return $this->update_size();
     }
     return parent::crop($src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs);
 }
開發者ID:roycocup,項目名稱:enclothed,代碼行數:65,代碼來源:class-pte-image-editor-imagick.php

示例6: watermark

 public function watermark($file, $mark_image, $set)
 {
     $image = new Imagick();
     $image->readImage($file);
     $watermark = new Imagick();
     $watermark->readImage($mark_image);
     $opacity = isset($set['wm_opacity']) ? (int) $set['wm_opacity'] : 100;
     $watermark->setImageOpacity($opacity / 100);
     $image->compositeImage($watermark, imagick::COMPOSITE_DEFAULT, $set['dest_x'], $set['dest_y']);
     $image->writeImage();
     $image->clear();
     $image->destroy();
     $watermark->clear();
     $watermark->destroy();
 }
開發者ID:sss201413,項目名稱:ecstore,代碼行數:15,代碼來源:imagick.php

示例7: crop

 /**
  * Crops Image.
  *
  * @since 3.5.0
  * @access public
  *
  * @param string|int $src The source file or Attachment ID.
  * @param int $src_x The start x position to crop from.
  * @param int $src_y The start y position to crop from.
  * @param int $src_w The width to crop.
  * @param int $src_h The height to crop.
  * @param int $dst_w Optional. The destination width.
  * @param int $dst_h Optional. The destination height.
  * @param boolean $src_abs Optional. If the source crop points are absolute.
  * @return boolean|WP_Error
  */
 public function crop($src_x, $src_y, $src_w, $src_h, $dst_w = null, $dst_h = null, $src_abs = false)
 {
     if (pte_is_crop_border_enabled($src_w, $src_h, $dst_w, $dst_h)) {
         // Crop the image to the correct aspect ratio...
         $ar = $src_w / $src_h;
         $dst_ar = $dst_w / $dst_h;
         if ($dst_ar > $ar) {
             // constrain to the dst_h
             $tmp_dst_h = $dst_h;
             $tmp_dst_w = $dst_h * $ar;
             $tmp_dst_y = 0;
             $tmp_dst_x = $dst_w / 2 - $tmp_dst_w / 2;
         } else {
             $tmp_dst_w = $dst_w;
             $tmp_dst_h = $dst_w / $ar;
             $tmp_dst_x = 0;
             $tmp_dst_y = $dst_h / 2 - $tmp_dst_h / 2;
         }
         if (pte_is_crop_border_opaque()) {
             $color = new ImagickPixel($_GET['pte-fit-crop-color']);
         }
         try {
             // crop the original image
             $this->image->cropImage($src_w, $src_h, $src_x, $src_y);
             $this->image->scaleImage($tmp_dst_w, $tmp_dst_h);
             // Create a new image and then compose the old one onto it.
             $img = new Imagick();
             $img->newImage($dst_w, $dst_h, isset($color) ? $color : 'white');
             $img->setImageFormat($this->image->getImageFormat());
             if (!isset($color)) {
                 $img->setImageOpacity(0.0);
             }
             $img->compositeImage($this->image, Imagick::COMPOSITE_DEFAULT, $tmp_dst_x, $tmp_dst_y);
             $img->flattenImages();
             $this->image = $img;
         } catch (Exception $e) {
             return new WP_Error('image_crop_error', __('Image crop failed.'), $this->file);
         }
         return $this->update_size();
     }
     return parent::crop($src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs);
 }
開發者ID:ilke-zilci,項目名稱:newcomers-wp,代碼行數:58,代碼來源:class-pte-image-editor-imagick.php

示例8: run

 public function run($file)
 {
     $image = new Imagick();
     $image->readImage($file);
     $watermark = new Imagick();
     $watermark->readImage($this->settings['overlay_path']);
     if (isset($this->settings['opacity']) === true && $this->settings['opacity'] != false) {
         $watermark->setImageOpacity($this->settings['opacity']);
     }
     /*
     		// how big are the images?
     		$iWidth = $image->getImageWidth();
     		$iHeight = $image->getImageHeight();
     		$wWidth = $watermark->getImageWidth();
     		$wHeight = $watermark->getImageHeight();
     
     		if ($iHeight < $wHeight || $iWidth < $wWidth) {
     		    // resize the watermark
     		    $watermark->scaleImage($iWidth, $iHeight);
     
     		    // get new size
     		    $wWidth = $watermark->getImageWidth();
     		    $wHeight = $watermark->getImageHeight();
     		}
     
     		// calculate the position
     		$x = ($iWidth - $wWidth) / 2;
     		$y = ($iHeight - $wHeight) / 2;
     */
     $image->compositeImage($watermark, imagick::COMPOSITE_OVER, $this->settings['horizontal_offset'], $this->settings['vertical_offset']);
     $image->writeImage($file);
     $image->clear();
     $image->destroy();
     $watermark->clear();
     $watermark->destroy();
     return TRUE;
 }
開發者ID:ayuinc,項目名稱:laboratoria-v2,代碼行數:37,代碼來源:action.im_watermark_image.php

示例9: watermark

 public function watermark($image = false, $parms = false)
 {
     if (!$image) {
         $image = CMS_Images::$default_watermark_image;
     }
     if (!$parms) {
         $parms = CMS_Images::$default_watermark_parms;
     }
     if (is_string($image)) {
         $image = preg_replace('{^/?}', '', $image);
         $watermark = new Imagick($image);
         list($w, $h) = CMS_Images::size($image);
     } elseif (is_object($image) && $image instanceof CMS_Image_Imagick) {
         $watermark =& $image->ih;
         $w = $image->width();
         $h = $image->height();
     }
     $_w = $this->width();
     $_h = $this->height();
     list($nl, $nt, $opacity) = $this->watermark_parms($parms, $_w, $_h, $w, $h);
     if ($opacity != 1) {
         $watermark->setImageOpacity($opacity);
     }
     $this->ih->compositeImage($watermark, Imagick::COMPOSITE_ATOP, $nl, $nt);
     return $this;
 }
開發者ID:techart,項目名稱:tao,代碼行數:26,代碼來源:Images.php

示例10: waterMarkImg

 function waterMarkImg()
 {
     if (empty($this->param['water_mark_image']) || !file_exists($this->param['water_mark_image'])) {
         return false;
     }
     $bg_h = $this->getHeight();
     $bg_w = $this->getWidth();
     $water_img = new Imagick($this->param['water_mark_image']);
     $water_h = $water_img->getImageHeight();
     $water_w = $water_img->getImageWidth();
     //if($bg_h < $water_h || $bg_w < $water_w )
     //{
     //   return false;
     //}
     if ($this->param['water_mark_opacity']) {
         $water_img->setImageOpacity($this->param['water_mark_opacity'] / 100);
     }
     $draw = new ImagickDraw();
     switch ($this->param['water_mark_pos']) {
         case 0:
         case 1:
             $gravity = Imagick::GRAVITY_NORTHWEST;
             //'NorthWest';
             break;
         case 2:
             $gravity = Imagick::GRAVITY_NORTH;
             //'North';
             break;
         case 3:
             $gravity = Imagick::GRAVITY_NORTHEAST;
             //'NorthEast';
             break;
         case 4:
             $gravity = Imagick::GRAVITY_WEST;
             //'West';
             break;
         case 5:
             $gravity = Imagick::GRAVITY_CENTER;
             //'Center';
             break;
         case 6:
             $gravity = Imagick::GRAVITY_EAST;
             //'East';
             break;
         case 7:
             $gravity = Imagick::GRAVITY_SOUTHWEST;
             //'SouthWest';
             break;
         case 8:
             $gravity = Imagick::GRAVITY_SOUTH;
             //'South';
             break;
         case 9:
             $gravity = Imagick::GRAVITY_SOUTHEAST;
             break;
     }
     $draw->setGravity($gravity);
     $draw->composite($water_img->getImageCompose(), 0, 0, 50, 0, $water_img);
     if ($this->image_type == 'GIF') {
         $color_transparent = new ImagickPixel("transparent");
         //透明色
         $dest = new Imagick();
         foreach ($this->image as $frame) {
             $page = $frame->getImagePage();
             $tmp = new Imagick();
             $tmp->newImage($page['width'], $page['height'], $color_transparent, 'gif');
             $tmp->compositeImage($frame, Imagick::COMPOSITE_OVER, $page['x'], $page['y']);
             $tmp->drawImage($draw);
             $dest->addImage($tmp);
             $dest->setImagePage($tmp->getImageWidth(), $tmp->getImageHeight(), 0, 0);
             $dest->setImageDelay($frame->getImageDelay());
             $dest->setImageDispose($frame->getImageDispose());
         }
         $dest->coalesceImages();
         $this->image->destroy();
         $this->image = $dest;
     } else {
         $this->image->drawImage($draw);
     }
 }
開發者ID:vluo,項目名稱:myPoto,代碼行數:80,代碼來源:image_imagick.php

示例11: post

if (isPost()) {
    // Get post parameters
    $originX = post('originX');
    $originY = post('originY');
    $transparency = post('transparency');
    $watermarkResize = post('markMin');
    $originalImagePath = post('originalImage');
    $watermarkImagePath = post('watermarkImage');
    // Open images
    $original = new Imagick($originalImagePath);
    $watermark = new Imagick($watermarkImagePath);
    // Set opacity for images with alpha channel and without
    if ($watermark->getImageAlphaChannel()) {
        $watermark->evaluateImage(Imagick::EVALUATE_DIVIDE, 1.0 / $transparency, Imagick::CHANNEL_ALPHA);
    } else {
        $watermark->setImageOpacity($transparency);
    }
    // Resize image
    if ($watermarkResize > 1) {
        $watermark->resizeImage($watermark->getImageWidth() / $watermarkResize, $watermark->getImageHeight() / $watermarkResize, Imagick::FILTER_LANCZOS, 1);
    }
    // Watermark block
    $isPattern = post('isPattern');
    if (bool($isPattern)) {
        // Get watermark`s offset from original image
        $initialX = (int) str_replace('px', '', post('x'));
        $initialY = (int) str_replace('px', '', post('y'));
        // Get watermark sizes
        $watermarkWidth = $watermark->getImageWidth();
        $watermarkHeight = $watermark->getImageHeight();
        // Get original image sizes
開發者ID:6thSence,項目名稱:Generator-of-watermarks,代碼行數:31,代碼來源:download.php

示例12:

 /**
  * Does a copy merge of two image resources
  *
  * @param Imagick $dst_im
  * @param Imagick $src_im
  * @param int $dst_x
  * @param int $dst_y
  * @param int $src_x
  * @param int $src_y
  * @param int $src_w
  * @param int $src_h
  * @param int $pct
  * @return bool
  */
 function zp_imageMerge($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct)
 {
     $src_im->cropImage($src_w, $src_h, $src_x, $src_y);
     $src_im->setImageOpacity($pct / 100);
     return $dst_im->compositeImage($src_im, Imagick::COMPOSITE_OVER, $dst_x, $dst_y);
 }
開發者ID:ariep,項目名稱:ZenPhoto20-DEV,代碼行數:20,代碼來源:lib-Imagick.php

示例13: addWaterMark

 /**
  * 加給圖片加水印
  * @param string $groundImage 要加水印地址
  * @param int $waterPos 水印位置
  * @param string $waterImage 水印圖片地址
  * @param string $waterText 文本文字
  * @param int $textFont 文字大小
  * @param string $textColor 文字顏色
  * @param int $minWidth 小於此值不加水印
  * @param int $minHeight 小於此值不加水印
  * @param float $alpha 透明度
  * @return FALSE
  */
 public static function addWaterMark($groundImage, $waterPos = 0, $waterImage = "", $waterText = "", $textFont = 15, $textColor = "#FF0000", $minWidth = 100, $minHeight = 100, $alpha = 0.9)
 {
     if (!class_exists('\\Imagick', false)) {
         return self::addWaterMark2($groundImage, $waterPos, $waterImage, $waterText, $textFont, $textColor, $minWidth, $minHeight, $alpha);
     }
     if (empty($waterText) and !is_file($waterImage)) {
         return false;
     }
     $bg = null;
     $bg_h = $bg_w = $water_h = $water_w = 0;
     //獲取背景圖的高,寬
     if (is_file($groundImage) && !empty($groundImage)) {
         $bg = new \Imagick();
         $bg->readImage($groundImage);
         $bg_h = $bg->getImageHeight();
         $bg_w = $bg->getImageWidth();
     }
     //獲取水印圖的高,寬
     $water = new \Imagick($waterImage);
     $water_h = $water->getImageHeight();
     $water_w = $water->getImageWidth();
     //如果背景圖的高寬小於水印圖的高寬或指定的高和寬則不加水印
     if ($bg_h < $minHeight || $bg_w < $minWidth || $bg_h < $water_h || $bg_w < $water_w) {
         return false;
     }
     //加水印
     $dw = new \ImagickDraw();
     //加圖片水印
     if (is_file($waterImage)) {
         $water->setImageOpacity($alpha);
         $dw->setGravity($waterPos);
         $dw->composite($water->getImageCompose(), 0, 0, 50, 0, $water);
         $bg->drawImage($dw);
         if (!$bg->writeImage($groundImage)) {
             return false;
         }
     } else {
         //加文字水印
         $dw->setFontSize($textFont);
         $dw->setFillColor($textColor);
         $dw->setGravity($waterPos);
         $dw->setFillAlpha($alpha);
         $dw->annotation(0, 0, $waterText);
         $bg->drawImage($dw);
         if (!$bg->writeImage($groundImage)) {
             return false;
         }
     }
     return true;
 }
開發者ID:matyhtf,項目名稱:swoole_framework,代碼行數:63,代碼來源:Image.php

示例14: resize

 /**
  * resize an image
  *
  * @param string  $from      file to convert
  * @param string  $to        convert to what
  * @param int     $width     width to convert to
  * @param int     $height    height to convert to
  * @param boolean $keepratio keep image ratio, or force an exact resize
  *
  * @return null
  */
 static function resize($from, $to, $width, $height, $keepratio = true)
 {
     if (!file_exists($from) && @fopen($from, 'r') != true) {
         return false;
     }
     switch (@$GLOBALS['DBVARS']['graphics-method']) {
         case 'imagick':
             // {
             $thumb = new Imagick();
             $thumb->read($from);
             $thumb->setImageOpacity(1.0);
             $thumb->resizeImage($width, $height, Imagick::FILTER_LANCZOS, 1, true);
             $thumb->writeImage($to);
             $thumb->clear();
             $thumb->destroy();
             break;
             // }
         // }
         default:
             // { fallback to GD
             $extFrom = CoreGraphics::getType($from);
             switch (preg_replace('/.*\\./', '', $to)) {
                 case 'png':
                     // {
                     $extTo = 'png';
                     break;
                     // }
                 // }
                 default:
                     $extTo = 'jpeg';
             }
             $size = getimagesize($from);
             if ($size === false) {
                 return false;
             }
             $load = 'imagecreatefrom' . $extFrom;
             $save = 'image' . $extTo;
             if (!function_exists($load) || !function_exists($save)) {
                 return false;
             }
             if (strpos($from, '/') !== 0) {
                 // external image
                 $tmp = USERBASE . '/ww.cache/' . md5($from) . '.' . $extFrom;
                 if (!file_exists($tmp)) {
                     copy($from, $tmp);
                 }
                 $im = $load($tmp);
                 unlink($tmp);
             } else {
                 $im = $load($from);
             }
             if ($keepratio) {
                 $multx = $size[0] / $width;
                 $multy = $size[1] / $height;
                 if ($multx > $multy) {
                     $mult = $multx;
                 } else {
                     $mult = $multy;
                 }
                 $width = $size[0] / $mult;
                 $height = $size[1] / $mult;
             }
             $imresized = imagecreatetruecolor($width, $height);
             imagealphablending($imresized, false);
             imagecopyresampled($imresized, $im, 0, 0, 0, 0, $width, $height, $size[0], $size[1]);
             imagesavealpha($imresized, true);
             $save($imresized, $to, $extTo == 'jpeg' ? 100 : 9);
             imagedestroy($imresized);
             imagedestroy($im);
             // }
     }
     return true;
 }
開發者ID:raylouis,項目名稱:kvwebme,代碼行數:84,代碼來源:CoreGraphics.php

示例15: do_watermark

	/**
	 * Apply watermark to image.
	 *
	 * @param	int		$attachment_id	Attachment ID
	 * @param	string	$image_path		Path to the file
	 * @param	string	$image_size		Image size
	 * @param	array	$upload_dir		Upload media data
	 * @return	void
	 */
	public function do_watermark( $attachment_id, $image_path, $image_size, $upload_dir ) {
		$options = apply_filters( 'iw_watermark_options', $this->options );

		// get image mime type
		$mime = wp_check_filetype( $image_path );

		// get watermark path
		$watermark_file = wp_get_attachment_metadata( $options['watermark_image']['url'], true );
		$watermark_path = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . $watermark_file['file'];

		// imagick extension
		if ( $this->extension === 'imagick' ) {
			// create image resource
			$image = new Imagick( $image_path );

			// create watermark resource
			$watermark = new Imagick( $watermark_path );

			// set transparency
			$image->setImageOpacity( round( 1 - (float)( $options['watermark_image']['transparent'] / 100 ), 2 ) );

			// set compression quality
			if ( $mime['type'] === 'image/jpeg' ) {
				$image->setImageCompressionQuality( $options['watermark_image']['quality'] );
				$image->setImageCompression( imagick::COMPRESSION_JPEG );
			} else
				$image->setImageCompressionQuality( $options['watermark_image']['quality'] );

			// set image output to progressive
			if ( $options['watermark_image']['jpeg_format'] === 'progressive' )
				$image->setImageInterlaceScheme( Imagick::INTERLACE_PLANE );

			// get image dimensions
			$image_dim = $image->getImageGeometry();

			// get watermark dimensions
			$watermark_dim = $watermark->getImageGeometry();

			// calculate watermark new dimensions
			list( $width, $height ) = $this->calculate_watermark_dimensions( $image_dim['width'], $image_dim['height'], $watermark_dim['width'], $watermark_dim['height'], $options );

			// resize watermark
			$watermark->resizeImage( $width, $height, imagick::FILTER_CATROM, 1 );

			// calculate image coordinates
			list( $dest_x, $dest_y ) = $this->calculate_image_coordinates( $image_dim['width'], $image_dim['height'], $width, $height, $options );

			// combine two images together
			$image->compositeImage( $watermark, Imagick::COMPOSITE_OVERLAY, $dest_x, $dest_y, Imagick::CHANNEL_ALL );

			// save watermarked image
			$image->writeImage( $image_path );

			// clear image memory
			$image->clear();
			$image->destroy();
			$image = null;

			// clear watermark memory
			$watermark->clear();
			$watermark->destroy();
			$watermark = null;
		// gd extension
		} else {
			// get image resource
			$image = $this->get_image_resource( $image_path, $mime['type'] );

			if ( $image !== false ) {
				// add watermark image to image
				$image = $this->add_watermark_image( $image, $options, $upload_dir );

				if ( $image !== false ) {
					// save watermarked image
					$this->save_image_file( $image, $mime['type'], $image_path, $options['watermark_image']['quality'] );

					// clear watermark memory
					imagedestroy( $image );

					$image = null;
				}
			}
		}
	}
開發者ID:recetasdemama,項目名稱:wordpress,代碼行數:92,代碼來源:image-watermark.php


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