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