本文整理汇总了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;
}
示例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;
}