GD library |Crop Image ||PHP
<?php
$image=imagecreatetruecolor(500, 600);
$bg=imagecolorallocate($image, 11, 22, 33);
imagefill($image, 0, 0, $bg);
$img=imagecrop($image, ['x' => 0, 'y' => 0, 'width' => 250, 'height' => 150]);
header('Content-type: image/png');
//imagepng($image);
imagepng($img, 'xy.png'); //save image
imagedestroy($image);