嗨,每次我都有一个允许用户旋转图像的按钮。但是,每次用户旋转图像(JPEG)时,质量都会变差。如何防止这种情况发生?
PHP 文件
//create src image and grab destination image from folder then...
imagecopyresampled($new_image, $src_image, 0, 0, 0, 0, $width, $height, $width, $height);
$rotated_image = imagerotate($new_image, $angle, 0);
imagejpeg($rotated_image, $new_image_file_path, 100);
JPEG是一种有损格式。 如果您不打算存储原件,则每次重新压缩时质量都会下降。
可以无损旋转JPEG,但GD和ImageMagick都不支持无损旋转。 您将需要找到一个这样做的库,或者手动实现算法。