PHP 图片矫正方法:GD 库和 ImageMagick
- 使用 PHP 内置的 GD 库:
使用 PHP 内置的 GD 库,可以使用函数 'imagerotate()' 来矫正图片的角度。
示例代码:
$source = imagecreatefromjpeg('source.jpg');
$rotate = imagerotate($source, 90, 0);
imagejpeg($rotate, 'rotate.jpg');
imagdestroy($source);
imagdestroy($rotate);
- 使用 ImageMagick:
使用 ImageMagick,可以使用函数 'exec()' 来执行命令行命令来矫正图片的角度。
示例代码:
exec('convert source.jpg -rotate 90 rotate.jpg');
原文地址: https://www.cveoy.top/t/topic/lj5V 著作权归作者所有。请勿转载和采集!