Extracts a region of the image.
Image
Start X
Start Y
Width
Height
Extracts a region of the image.
Parameters
widthintThe width of the crop
heightintThe height of the crop
xintThe X coordinate of the cropped region's top left corner
yintThe Y coordinate of the cropped region's top left corner
function cropImage($imagePath, $startX, $startY, $width, $height)
{
    $imagick = new \Imagick(realpath($imagePath));
    $imagick->cropImage($width, $height, $startX, $startY);
    header("Content-Type: image/jpg");
    echo $imagick->getImageBlob();
}