I have an image which it is strange, The EXIF Orientation tag is 8 (left bottom, i.e. rotate 270 CW)

Image source: https://drive.google.com/file/d/1WQOuy4wZpofvSLu3p6TmiOQI-udN7ooS/view?usp=sharing

I used 2 different software to open it (with or without auto rotation), one is XViewer 2.4.3 (Linux Mint 19.3 Cinanmon), one is IrfanView (Windows 11).

In XViewer with and without auto rotation in viewer is like this, you can see it is auto rotated 270 CW enter image description here

IrfanView like this (no auto rotation occurs in IrfanView): enter image description here

According to the EXIF, XViewer is correct, why IrfanView not rotate?

And I put the image to the browser (Chrome and Edge), it is also NOT rotated by the browser, why? Why the EXIF not reflected in either browser or IrfanView (for this image only, I tried other image, it is fine...), what is the problem of this image?


3 Answers 3


The problem here is that whatever program wrote the Orientation tag wrote it in the wrong place. It is supposed to be in the IFD0 subgroup of the EXIF block, but in your file, it is in the IFD1 subgroup.

Using exiftool on your file results in this output

C:\>exiftool -G1 -a -s -orientation Y:\!temp\x\y\z\rotate-test-2024.jpg
[IFD1]          Orientation                     : Rotate 270 CW

Using the same command on a picture I just took with my Nikon

C:\>exiftool -G1 -a -s -orientation Y:/!temp/x/y/z/100D5100/DSC_0001.JPG
[IFD0]          Orientation                     : Rotate 270 CW

Your results show that XViewer is more flexible about the location of the Orientation than the other programs, which are more closely following the EXIF specs.

Note that it isn't uncommon for cameras to write data to the incorrect location, but they usually they do so in addition to writing the correct location. For example, the same command with my cheapy Samsung phone

C:\>exiftool -G1 -a -s -orientation Y:\!temp\x\y\z\20240108_082356.jpg
[IFD0]          Orientation                     : Horizontal (normal)
[IFD1]          Orientation                     : Horizontal (normal)
  • 2
    \$\begingroup\$ I just looked up the EXIF spec, and IFD0 is nominally the data for the main image, and IFD1 for the thumbnail. \$\endgroup\$
    – Peter M
    Jan 8 at 17:06
  • \$\begingroup\$ So I use the IrfanView to check for the EXIF data, it can show the Orientation tag, and is it matter if Orientation locate at IFD0 or IFD1? \$\endgroup\$
    – saycchai
    Jan 9 at 6:55
  • \$\begingroup\$ @StarGeek, so I need to update my Orientation to the IFD0, then it will auto rotate properly in all IrfanView or the browser? \$\endgroup\$
    – saycchai
    Jan 9 at 11:04
  • \$\begingroup\$ If the image is already rotated correctly, as your example image shows, then you don't need the Orientation tag. You can remove it completely. You only need it if the image actually has to be rotated to be shown correctly. \$\endgroup\$
    – StarGeek
    Jan 9 at 15:38
  • \$\begingroup\$ Checking your image, Irfanview correctly indicates that the only Orientation tag applies to the thumbnail. You have to open the EXIF viewer and scroll all the way down to see it. \$\endgroup\$
    – StarGeek
    Jan 9 at 15:41

My explanation:

Cameras encode the image the same way, directly from the sensor. This encoding is independent of the camera orientation and is natively in landscape mode (Width > Height). To display the image with the proper orientation, the EXIF orientation flags is added.

Smartphones either do it like cameras, or encode the image it its intended display orientation, and use an EXIF orientation of 1 (no rotation).

In both cases you don't see an out-of-camera portrait-encoded photo with an EXIF orientation flag other than 1.

Photo editors normally encode the image in its intended orientation, and reset the orientation flag.

However, in a not so distant past, the Windows photo viewer (up to Windows XP IIRC) would ignore the EXIF orientation, and show portrait pictures on the side. And when you asked it to rotate the picture for display, it would comply, save the file back to disk... with the initial EXIF rotation. So, in other software, the portrait orientation would become a landscape orientation again.

So, it makes sense that to avoid this mess, an image viewer would be very suspicious of an EXIF orientation flag other than top-left on any portrait-encoded image (Width < Height) and prefer to ignore it. In 2024, it can be a bug, in 1996 (birth date or IrfanView, so in the Windows95 era) it was a very welcome feature...

I suggest you do the same test with an image which is encoded in landscape mode to see if in this case IrfanView abides to the EXIF rotation.

  • \$\begingroup\$ Exif orientation is used to indicate the orientation of the image. It has nothing to do with aspect ratio. Irfanview does not do any check of orientation against aspect ratio. Rewriting the metadata with exiftool -tagsfromfile=rotate-test-2024.jpg rotate-test-2024.jpg allows Irfanview to display the image as expected, indicating that there is a problem with the metadata. \$\endgroup\$
    – xiota
    Jan 8 at 13:58
  • 2
    \$\begingroup\$ I know... The whole point here is that this applies most of the time to an image encoded as landscape (because that's how cameras work). An image encoded as portrait with an EXIF for rotation? Very rare, and for a very long time it was a mistake. \$\endgroup\$
    – xenoid
    Jan 8 at 15:49

I recommend opening the image in Photoshop or another image editor and saving it out with actual rotation. The metadata should work but can be out of sync with the actual image pixels.

  • \$\begingroup\$ This is not a lossless operation. \$\endgroup\$
    – wizzwizz4
    Jan 8 at 21:24
  • \$\begingroup\$ @wizzwizz4 rotation by multiples of 90 degrees can be lossless, but usually that's a special operation unrelated to regular rotation. And it only works if the image dimensions are evenly divisible by 16. \$\endgroup\$ Jan 8 at 22:44
  • \$\begingroup\$ @MarkRansom I don't know whether Photoshop's JPEG encoder will use the same parameters as the image's original encoding. I wouldn't expect it to. \$\endgroup\$
    – wizzwizz4
    Jan 9 at 0:14
  • \$\begingroup\$ Sorry I do not have Photoshop \$\endgroup\$
    – saycchai
    Jan 9 at 6:54
  • 1
    \$\begingroup\$ @wizzwizz4 I don't know if Photoshop has the special function I was talking about. It works by rotating the raw JPEG blocks themselves, no decoding or encoding necessary. \$\endgroup\$ Jan 9 at 12:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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