Comfortability method for setting image size. The method sets the image size and allows setting x,y coordinates where the new area begins. Available since 6.3.1
Image
Comfortability method for setting image size. The method sets the image size and allows setting x,y coordinates where the new area begins. Available since 6.3.1
Parameters
widthintThe new width
heightintThe new height
xintX position for the new size
yintY position for the new size
function extentImage($imagePath)
{
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->setImageBackgroundColor('orange');
    $imagick->extentImage(
        $imagick->getImageWidth(),
        $imagick->getImageHeight(),
        -100,
        -100
    );

    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}