2013-10-15 91 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都不支持無損旋轉。您需要找到一個能夠手動執行算法的庫。