13

As JPG is a lossy compression, every re-encoding losses quality. Thus, 90/180/270 degree rotation is a lossy operation as well. Is it possible to change orientation of JPG photo by changing some of its metadata tags so that the orientation can be changed without re-encoding the photo?

  • When you say "change orientation" do you mean "rotate by 90/180/270", "flip" (L/R or U/D) or both? (obviously not by any angle that isn't a multiple of 90º) – smci Dec 5 '20 at 3:49
17

JPG can be rotated using only EXIF data, so no re-encoding is necessary.

I found this tutorial on the orientation flag - JPEG Rotation and EXIF Orientation

These days, most image apps can handle this flag, many can also write it.

Exiftool is a very comprehensive multi-platform solution that can handle all exif data - see How can I modify the EXIF orientation tag of an image?

  • 1
    Thanks! I also found a solution using ExifTool. And I also found that IrfanView can do a lossless rotation (menu Options / JPG lossless rotation), do you know if it works via EXIF as well? :-) – Tomas Dec 4 '20 at 13:12
  • 15
    jpeg images can be really lossless rotated by 90 degrees (see stackoverflow.com/questions/543402/…) – xanatos Dec 4 '20 at 20:59
  • 2
    @Tomas photo.stackexchange.com/a/104366 IrfanView can indeed rotate JPEG images in a lossless way, and it indeed needs the JPG_TRANSFORM plugin to do that. Luckily that plugin is already included in a normal install of IrfanView. To check you have the plugin: go to Help -> Installed PlugIns and check if JPG_TRANSFORM.DLL is in the list. – xanatos Dec 4 '20 at 22:46
  • 4
    Note that a lossless true rotation is only possible if the image size is a multiple of the block size in both dimensions (depending on the subsampling options used, the block size may be 8x8, 8x16, 16x8 or 16x16). – plugwash Dec 5 '20 at 1:29
  • 1
    Note that a lossless true rotation is only possible if the image size is a multiple of the block size in both dimensions - Forsooth, IrfanView will give an error if you try to use the lossless-rotation function on images that have incompatible dimensions. Still, most unmodified images (straight from the camera, screenshot tool, etc.) will have compatible dimensions. – Synetech Dec 5 '20 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.