Image rotation reduces quality

I have a page where the user can rotate the images left and right.

The problem is that when the user rotates the image 4-5 times, the quality is significantly reduced!

Am I doing wrong?

$image_source = imagecreatefromjpeg($path_u); $rotate = imagerotate($image_source, $angle, 0); imageinterlace($rotate, true); //this is to create progressive jpeg imagejpeg($rotate, $path_u, 100); imagedestroy($rotate); 
+4
source share
2 answers

Repeated alteration and re-compression of the image (especially in JPEG, which is lost regardless of the quality setting) will inevitably lead to multiplicative artifacts. You would be better off saving the original image, and when you need to rotate, rotate the original again, and not save the original every time.

+4
source

Please correct me if I am wrong, but in 2014 we can rotate jpeg images, not without loss of quality, but seriously reducing it.

The Imagejpeg method has an argument of "quality", which helps to establish the desired preservation of quality. 100 for the value is excellent.

I tried several times to rotate the same image, and the loss of quality is actually not visible to human eyes.

Here is the code.

  header("Content-type: image/jpeg"); $source = imagecreatefromjpeg($pictureUrl); $rotate = imagerotate($source, $degrees, 0); imagejpeg($rotate, $pictureUrl, 100); imagedestroy($source); imagedestroy($rotate); 
-1
source

All Articles