(PECL imagick 2, PECL imagick 3)
Imagick::posterizeImage — Reduces the image to a limited number of color level
$levels
, bool $dither
): boolReduces the image to a limited number of color level.
levels
dither
Returns true
on success.
Example #1 Imagick::posterizeImage()
<?php
function posterizeImage($imagePath, $posterizeType, $numberLevels) {
$imagick = new \Imagick(realpath($imagePath));
$imagick->posterizeImage($numberLevels, $posterizeType);
$imagick->setImageFormat('png');
header("Content-Type: image/png");
echo $imagick->getImageBlob();
}
posterizeImage($imagePath, \Imagick::DITHERMETHOD_RIEMERSMA, 8);
?>