HomeImagickImagickDrawImagickPixelImagick Pixel IteratorImagick KernelDevelopmentTutorial Source codeReport an issue
Category
Example

Imagick::orderedPosterizeImage

← orderedDitherImage   paintOpaqueImage →

From the ImageMagick manual for MagickOrderedPosterizeImage: A string containing the name of the threshold dither map to use, followed by zero or more numbers representing the number of color levels tho dither between.

For example: "o3x3,6" generates a 6 level posterization of the image with a ordered 3x3 diffused pixel dither being applied between each level. While checker,8,8,4 will produce a 332 colormaped image with only a single checkerboard hash pattern (50 grey) between each color level, to basically double the number of color levels with a bare minimim of dithering.
¯\_(ツ)_/¯

The predefined posterization types available are defined in the ImageMagick file: config/thresholds.xml
Doesn't exist on ImageMagick 7 - TODO - need to find equivalent.

Example

function orderedPosterizeImage($image_path, $orderedPosterizeType)
{
    $imagick = new \Imagick(realpath($image_path));
    $imagick->orderedPosterizeImage($orderedPosterizeType);
    $imagick->setImageFormat('png');
    
    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}