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


PHP ImageInterface::layers方法代碼示例

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


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

示例1: resize

	/**
	 * Re-sizes the image. If $height is not specified, it will default to $width, creating a square.
	 *
	 * @param int      $targetWidth
	 * @param int|null $targetHeight
	 *
	 * @return Image
	 */
	public function resize($targetWidth, $targetHeight = null)
	{
		$this->_normalizeDimensions($targetWidth, $targetHeight);

		if ($this->_isAnimatedGif)
		{

			// Create a new image instance to avoid object references messing up our dimensions.
			$newSize = new \Imagine\Image\Box($targetWidth, $targetHeight);
			$gif = $this->_instance->create($newSize);
			$gif->layers()->remove(0);

			foreach ($this->_image->layers() as $layer)
			{
				$resizedLayer = $layer->resize($newSize, $this->_getResizeFilter());
				$gif->layers()->add($resizedLayer);
			}

			$this->_image = $gif;
		}
		else
		{
			$this->_image->resize(new \Imagine\Image\Box($targetWidth, $targetHeight), $this->_getResizeFilter());
		}

		return $this;
	}
開發者ID:harish94,項目名稱:Craft-Release,代碼行數:35,代碼來源:Image.php

示例2: resize

 /**
  * Re-sizes the image. If $height is not specified, it will default to $width, creating a square.
  *
  * @param int      $targetWidth
  * @param int|null $targetHeight
  *
  * @return Image
  */
 public function resize($targetWidth, $targetHeight = null)
 {
     $this->normalizeDimensions($targetWidth, $targetHeight);
     if ($this->_isAnimatedGif) {
         $this->_image->layers()->coalesce();
         // Create a new image instance to avoid object references messing up our dimensions.
         $newSize = new \Imagine\Image\Box($targetWidth, $targetHeight);
         $gif = $this->_instance->create($newSize);
         $gif->layers()->remove(0);
         foreach ($this->_image->layers() as $layer) {
             $resizedLayer = $layer->resize($newSize, $this->_getResizeFilter());
             $gif->layers()->add($resizedLayer);
             // Let's update dateUpdated in case this is going to take awhile.
             if ($index = craft()->assetTransforms->getActiveTransformIndexModel()) {
                 craft()->assetTransforms->storeTransformIndexData($index);
             }
         }
         $this->_image = $gif;
     } else {
         if (craft()->images->isImagick()) {
             $this->_image->smartResize(new \Imagine\Image\Box($targetWidth, $targetHeight), (bool) craft()->config->get('preserveImageColorProfiles'), $this->_quality);
         } else {
             $this->_image->resize(new \Imagine\Image\Box($targetWidth, $targetHeight), $this->_getResizeFilter());
         }
     }
     return $this;
 }
開發者ID:vescoyez,項目名稱:portfolio_v2,代碼行數:35,代碼來源:Image.php

示例3: resize

 /**
  * Re-sizes the image. If $height is not specified, it will default to $width, creating a square.
  *
  * @param int      $targetWidth
  * @param int|null $targetHeight
  *
  * @return Image
  */
 public function resize($targetWidth, $targetHeight = null)
 {
     $this->normalizeDimensions($targetWidth, $targetHeight);
     if ($this->_isAnimatedGif) {
         // Create a new image instance to avoid object references messing up our dimensions.
         $newSize = new \Imagine\Image\Box($targetWidth, $targetHeight);
         $gif = $this->_instance->create($newSize);
         $gif->layers()->remove(0);
         foreach ($this->_image->layers() as $layer) {
             $resizedLayer = $layer->resize($newSize, $this->_getResizeFilter());
             $gif->layers()->add($resizedLayer);
         }
         $this->_image = $gif;
     } else {
         if (craft()->images->isImagick()) {
             $this->_image->smartResize(new \Imagine\Image\Box($targetWidth, $targetHeight), (bool) craft()->config->get('preserveImageColorProfiles'), $this->_quality);
         } else {
             $this->_image->resize(new \Imagine\Image\Box($targetWidth, $targetHeight), $this->_getResizeFilter());
         }
     }
     return $this;
 }
開發者ID:paulcarvill,項目名稱:Convergence-craft,代碼行數:30,代碼來源:Image.php

示例4: getOptionsFromImage

 /**
  * @param ImageInterface $image
  * @param string         $imageExtension
  * @param array          $formatOptions
  *
  * @return array
  */
 protected function getOptionsFromImage(ImageInterface $image, $imageExtension, $formatOptions)
 {
     $options = [];
     if (count($image->layers()) > 1 && $imageExtension == 'gif') {
         $options['animated'] = true;
     }
     return array_merge($options, $formatOptions);
 }
開發者ID:Silwereth,項目名稱:sulu,代碼行數:15,代碼來源:FormatManager.php


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