简体   繁体   中英

how to crop a jpg image only with php?

using ImageMagic the cropping can be done easily with below code , but it's impossible to install ImageMagic in the hosting server.so is there any way to do this with only php? need to crop jpg images not png. and how to stop reducing the quality og the image?

$image = new Imagick($inFile);
list($width, $height) = getimagesize($inFile);
$image->cropImage($width,$height-60, -60,0);
$image->writeImage($outFile);

Here is some alternatives for cropping images:

Use composer package intervention\\image :

https://packagist.org/packages/intervention/image

Use image manipulation as a service by cloudinary (it's powerful and free/cheap simple image manipulation and storage on cloud):

http://cloudinary.com

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM