To get the center crop of a image in php:
$new = imagecreatefromjpeg($uploadedfile);
$crop_width = imagesx($new);
$crop_height = imagesy($new);
$size = min($crop_width, $crop_height);
if($crop_width >= $crop_height) {
$newx= ($crop_width-$crop_height)/2;
$im2 = imagecrop($new, ['x' => $newx, 'y' => 0, 'width' => $size, 'height' => $size]);
}
else {
$newy= ($crop_height-$crop_width)/2;
$im2 = imagecrop($new, ['x' => 0, 'y' => $newy, 'width' => $size, 'height' => $size]);
}
imagejpeg($im2,$filename,90);