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. Available since 6.2.9
Width
Height
Image
Best fit
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. Available since 6.2.9
Parameters
columnsintThe number of columns in the scaled image.
rowsintThe number of rows in the scaled image.
bestfitboolWhether to fit the image inside a bounding box.
function adaptiveResizeImage($imagePath, $width, $height, $bestFit)
{
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->adaptiveResizeImage($width, $height, $bestFit);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}