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?
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