HomeImagickImagickDrawImagickPixelImagick Pixel IteratorImagick KernelDevelopmentTutorial Source codeReport an issue
Category
Example

Adaptive resize image

← adaptiveBlurImage   adaptiveSharpenImage →
Adaptively resize image with data-dependent triangulation. Avoids blurring across sharp color changes. Most useful when used to shrink images slightly to a slightly smaller "web size"; may not look good when a full-sized image is adaptively resized to a thumbnail. This method is available if Imagick has been compiled against ImageMagick version 6.2.9 or newer.

Example

function adaptiveResizeImage($image_path, $width, $height, $bestFit)
{
    $imagick = new \Imagick(realpath($image_path));
    $imagick->adaptiveResizeImage($width, $height, $bestFit);
    header("Content-Type: image/jpeg");
    echo $imagick->getImageBlob();
}