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