2013-10-15 51 views
0

大家好我每次都有一个允许用户旋转图像的按钮。然而,每当用户旋转图像(这是一个JPEG),质量就会变差。我如何防止这种情况发生?PHP图像编辑:每次编辑后图像质量都会变差

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); 

回答

1

JPEG是一种有损格式。如果您不打算保存原件,每次重新压缩时质量都会降低。

有可能losslessly rotate a JPEG,但GD和ImageMagick都不支持无损旋转。您需要找到一个能够手动执行算法的库。