Replaces colors an image with those defined by replacement. The colors are replaced with the closest possible color. Available since 6.4.5
Touch/mouse over to see original View modified in new window.
Image
Dither method
Replaces colors an image with those defined by replacement. The colors are replaced with the closest possible color. Available since 6.4.5
Parameters
replacementImagickAn Imagick object containing the replacement colors
DITHERintRefer to this list of dither method constants
function remapImage($imagePath, $ditherMethod)
{
    $imagick = new \Imagick(realpath($imagePath));
    $imagick2 = new \Imagick(realpath("images/VGA_palette_with_black_borders.png"));
    $palette = new \Imagick(realpath("images/NetscapeWebSafeColours.gif"));
    $imagick->remapImage($palette, $ditherMethod);
    header("Content-Type: image/png");
    echo $imagick->getImageBlob();
}