本文整理匯總了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);
}