This is Cropping images with PHP....
*Remember imagejpeg() and imagecreatefromjpeg() will only work for jpeg images....
for png images just replace jpeg word with png (eg. imagepng()) and
the final step would be imagepng($truecolo,$newfile,9); (1-9)
[+] Sample project link : https://github.com/kharbanda14/youtub...
This could also work for crop if you change the parameters accordingly.