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?
Is it possible to change orientation of JPG image without rotating it (and thus losing information)?
1 Answer
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?
-
1Thanks! 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? :-)– TomasDec 4, 2020 at 13:12
-
16jpeg images can be really lossless rotated by 90 degrees (see stackoverflow.com/questions/543402/…)– xanatosDec 4, 2020 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.– xanatosDec 4, 2020 at 22:46
-
5Note 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).– plugwashDec 5, 2020 at 1:29
-
2
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.– SynetechDec 5, 2020 at 15:44