You can use imagecrop() method to crop any image as follows:
$filename = 'test.JPG';
$image = imagecreatefromjpeg($filename );
$x_size = getimagesize($filename)[0];
$y_size = getimagesize($filename)[1];
$crop_measure = min($x_size, $y_size);
header('Content-Type: image/jpeg');
$crop_array = array('x' =>0 , 'y' => 0, 'width' => $crop_measure, 'height'=> $crop_measure);
$thumb_image = imagecrop($image, $crop_array);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.