当前位置: 首页>>代码示例>>PHP>>正文


PHP ImageInterface::smartResize方法代码示例

本文整理汇总了PHP中Imagine\Image\ImageInterface::smartResize方法的典型用法代码示例。如果您正苦于以下问题:PHP ImageInterface::smartResize方法的具体用法?PHP ImageInterface::smartResize怎么用?PHP ImageInterface::smartResize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Imagine\Image\ImageInterface的用法示例。


在下文中一共展示了ImageInterface::smartResize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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) {
         $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

示例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) {
         // 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


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