HomeImagickImagickDrawImagickPixelImagick Pixel IteratorImagick KernelDevelopmentTutorial Source codeReport an issue
Category
Example

Imagick::kmeansImage

← importImagePixels   levelImage →

Example

function kmeansImage(
    $image_path,
    int $number_colors,
    int $max_iterations,
    float $tolerance
) {
    $imagick = new \Imagick(realpath($image_path));
    $imagick->kmeansImage($number_colors, $max_iterations, $tolerance);
    header("Content-Type: image/jpeg");
    echo $imagick->getImageBlob();
}