本文整理匯總了PHP中Imagine\Image\ImageInterface::getImagick方法的典型用法代碼示例。如果您正苦於以下問題:PHP ImageInterface::getImagick方法的具體用法?PHP ImageInterface::getImagick怎麽用?PHP ImageInterface::getImagick使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Imagine\Image\ImageInterface
的用法示例。
在下文中一共展示了ImageInterface::getImagick方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: isTransparent
/**
* Returns true if Imagick is installed and says that the image is transparent.
*
* @return bool
*/
public function isTransparent()
{
if (craft()->images->isImagick() && method_exists("Imagick", "getImageAlphaChannel")) {
return $this->_image->getImagick()->getImageAlphaChannel();
}
return false;
}
示例2: apply
/**
* @param ImageInterface|\Imagine\Imagick\Image $image
*
* @return ImageInterface
*/
public function apply(ImageInterface $image)
{
/** @var \Imagick $imagick */
$imagick = $image->getImagick();
$imagick->swirlImage((double) $this->getOption('degrees', 60));
return $image;
}
示例3: apply
/**
* @param ImageInterface|\Imagine\Imagick\Image $image
*
* @return ImageInterface
*/
public function apply(ImageInterface $image)
{
/** @var \Imagick $imagick */
$imagick = $image->getImagick();
$imagick->reduceNoiseImage((double) $this->getOption('radius', 0));
return $image;
}
示例4: _getSaveOptions
/**
* Get save options.
*
* @param int|null $quality
* @param string $extension
* @return array
*/
private function _getSaveOptions($quality = null, $extension = null)
{
$quality = !$quality ? $this->_quality : $quality;
$extension = !$extension ? $this->getExtension() : $extension;
switch ($extension) {
case 'jpeg':
case 'jpg':
return array('jpeg_quality' => $quality, 'flatten' => true);
case 'gif':
$options = array('animated' => $this->_isAnimatedGif);
if ($this->_isAnimatedGif) {
// Imagine library does not provide this value and arbitrarily divides it by 10, when assigning,
// so we have to improvise a little
$options['animated.delay'] = $this->_image->getImagick()->getImageDelay() * 10;
}
return $options;
case 'png':
// Valid PNG quality settings are 0-9, so normalize since we're calculating based on 0-200.
$percentage = $quality * 100 / 200;
$normalizedQuality = round($percentage / 100 * 9);
return array('png_compression_level' => $normalizedQuality, 'flatten' => false);
default:
return array();
}
}
示例5: _getSaveOptions
/**
* Get save options.
*
* @param int|null $quality
* @param string $extension
* @return array
*/
private function _getSaveOptions($quality = null, $extension = null)
{
// Because it's possible for someone to set the quality to 0.
$quality = $quality === null || $quality === false ? $this->_quality : $quality;
$extension = !$extension ? $this->getExtension() : $extension;
switch ($extension) {
case 'jpeg':
case 'jpg':
return array('jpeg_quality' => $quality, 'flatten' => true);
case 'gif':
$options = array('animated' => $this->_isAnimatedGif);
if ($this->_isAnimatedGif) {
// Imagine library does not provide this value and arbitrarily divides it by 10, when assigning,
// so we have to improvise a little
$options['animated.delay'] = $this->_image->getImagick()->getImageDelay() * 10;
}
return $options;
case 'png':
// Valid PNG quality settings are 0-9, so normalize and flip, because we're talking about compression
// levels, not quality, like jpg and gif.
$normalizedQuality = round($quality * 9 / 100);
$normalizedQuality = 9 - $normalizedQuality;
if ($normalizedQuality < 0) {
$normalizedQuality = 0;
}
if ($normalizedQuality > 9) {
$normalizedQuality = 9;
}
return array('png_compression_level' => $normalizedQuality, 'flatten' => false);
default:
return array();
}
}
示例6: _getSaveOptions
/**
* Get save options.
*
* @param int|null $quality
* @param string $extension
* @return array
*/
private function _getSaveOptions($quality = null, $extension = null)
{
// Because it's possible for someone to set the quality to 0.
$quality = $quality === null || $quality === false ? $this->_quality : $quality;
$extension = !$extension ? $this->getExtension() : $extension;
switch ($extension) {
case 'jpeg':
case 'jpg':
return array('jpeg_quality' => $quality, 'flatten' => true);
case 'gif':
$options = array('animated' => $this->_isAnimatedGif);
if ($this->_isAnimatedGif) {
// Imagine library does not provide this value and arbitrarily divides it by 10, when assigning,
// so we have to improvise a little
$options['animated.delay'] = $this->_image->getImagick()->getImageDelay() * 10;
}
return $options;
case 'png':
// Valid PNG quality settings are 0-9, so normalize and flip, because we're talking about compression
// levels, not quality, like jpg and gif.
$normalizedQuality = round($quality * 9 / 100);
$normalizedQuality = 9 - $normalizedQuality;
if ($normalizedQuality < 0) {
$normalizedQuality = 0;
}
if ($normalizedQuality > 9) {
$normalizedQuality = 9;
}
$options = array('png_compression_level' => $normalizedQuality, 'flatten' => false);
$pngInfo = ImageHelper::getPngImageInfo($this->_imageSourcePath);
// Even though a 2 channel PNG is valid (Grayscale with alpha channel), Imagick doesn't recognize it as
// a valid format: http://www.imagemagick.org/script/formats.php
// So 2 channel PNGs get converted to 4 channel.
if (is_array($pngInfo) && isset($pngInfo['channels']) && $pngInfo['channels'] !== 2) {
$format = 'png' . 8 * $pngInfo['channels'];
} else {
$format = 'png32';
}
$options['png_format'] = $format;
return $options;
default:
return array();
}
}
示例7: getImageResolution
protected function getImageResolution(ImageInterface $image)
{
return $image->getImagick()->getImageResolution();
}