image crop from the original image via below code, It’s crop by height, width, x and y of sub-image.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
<?php // It's work only png format image. $orginalImagePath="orginal.png"; $cropImagePath="crop.png"; $im = imagecreatefrompng($orginalImagePath); $im_crop = imagecrop($im, ['x' => $dimension['x'], 'y' => $dimension['y'], 'width' => $dimension['w'], 'height' => $dimension['h']]); if ($im_crop !== FALSE) { imagepng($im_crop, $cropImagePath, "7"); imagedestroy($im2); } imagedestroy($im); ?> |
More Stories
CPU & Memory usage in PHP
Install PHP mcrypt extension on Ubuntu
Text to speech