array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'zh', ), 'this' => array ( 0 => 'imagick.quantizeimage.php', 1 => 'Imagick::quantizeImage', ), 'up' => array ( 0 => 'class.imagick.php', 1 => 'Imagick', ), 'prev' => array ( 0 => 'imagick.profileimage.php', 1 => 'Imagick::profileImage', ), 'next' => array ( 0 => 'imagick.quantizeimages.php', 1 => 'Imagick::quantizeImages', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/imagick/imagick/quantizeimage.xml', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PECL imagick 2, PECL imagick 3)
Imagick::quantizeImage — Analyzes the colors within a reference image
numberColors
colorspace
treedepth
dither
measureError
成功时返回 true
。
错误时抛出 ImagickException。
示例 #1 Imagick::quantizeImage()
<?php
function quantizeImage($imagePath, $numberColors, $colorSpace, $treeDepth, $dither) {
$imagick = new \Imagick(realpath($imagePath));
$imagick->quantizeImage($numberColors, $colorSpace, $treeDepth, $dither, false);
$imagick->setImageFormat('png');
header("Content-Type: image/png");
echo $imagick->getImageBlob();
}
?>