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