Can a JPEG compressed image be rotated without a loss in quality?

Mat picture Mat · Feb 12, 2009 · Viewed 10.3k times · Source

JPEG is a lossy compression scheme, so decompression-manipulation-recompression normally reduces the image quality further for each step. Is it possible to rotate a JPEG image without incurring further loss? From what little I know of the JPEG algorithm, it naively seems possible to avoid further loss with a bit of effort. Which common image manipulation programs (e.g. GIMP, Paint Shop Pro, Windows Photo Gallery) and graphic libraries cause quality loss when performing a rotation and which don't?

Answer

kcwu picture kcwu · May 15, 2009

There is a program named jpegtran

jpegtran – a utility for lossless transcoding between different JPEG formats.

To rotate the image losslessly, you can do the following:

$ jpegtran -rotate 180 -perfect -outfile rotated.jpg origin.jpg

And Here is a list of applications which provide the JPEG lossless rotation feature based on the IJG code