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