Crop an image | PHP

June 26th, 2021 01:17:50 PM

					
<?php $im = imagecreatefrompng('example.png'); $size = min(imagesx($im), imagesy($im)); $im2 = imagecrop($im, ['x' => 0, 'y' => 0, 'width' => $size, 'height' => $size]); if ($im2 !== FALSE) { imagepng($im2, 'example-cropped.png'); imagedestroy($im2); } imagedestroy($im); ?>

Featured Posts