Image rotation variable according to the source

It seems that I have detected the following bug.
I created 2 buttons to rotate the images in the lister:
For the first one: on a portrait image, the rotation will be 180° to the left instead of 90. For a landscape image, it works as expected.
For the 2nd : on a portrait image, the first press on the button does nothing. The 2nd one does rotate the image 90° to the right. For a landscape image, it works from the first press on the button, with a 90° rotation to the right.

Can you reproduce the problem and if so correct it?

Might be an effect of the settings Preferences / Viewer / Appearance / Use EXIF information (if present) to auto-rotate pictures in Opus and/or the rotation tag in the pictures.

Hi lxp,
It was a good idea.
I have this option enabled. I tried disabling this option, but the result is the same.

What does the Rotation column show for the images before and after?

Where are you viewing the images to judge the results? The viewer pane, standalone viewer, and thumbnails mode, as well as the image converter, all have their own settings for whether or not they consider EXIF rotation tags. Third party software can also use or not use them, depending on the software and configuration.

You can use Image ROTATE=EXIF HERE REPLACE to apply the current EXIF rotation to images' pixels and clear the rotation field, or Image ROTATE=reset HERE REPLACE to clear the rotation field without changing the pixels.

Give us some sample input images and we can try.

Be sure to zip them, rather than attaching them directly, so the forum doesn't destroy the EXIF rotation data.

I begin to understand that it comes from the orientation field, generated by my Xiaomi smartphone.
Attached a photo where the orientation has been detected incorrectly and I want to rotate 90° to the left.
Orientation field is 270°


Rotate of 180° (instead of -90 or 270°)
Orientation field becomes 0°

Now just to test :


Rotate of 0° (instead of 90°)
Orientation field becomes 0°


Rotate of 0°
Orientation field becomes 0°


Rotate of -90° !
Orientation field becomes 0°
=> So the only command that works for my case.

Test (4.2 MB)

1 Like

Many thanks!

I can reproduce the problem with that image. Have not worked out why it's like that yet, but we'll investigate.

1 Like

Looks like this image cannot be rotated losslessly. I'd only use ROTATE=reset to maintain image quality.

To complete : on another image, which have 0° in orientation field, the rotation angle works as expected.

I've looked into this in detail and have realised it's not really a bug, although it is something we might change to make things easier to understand.

Essentially, the Image Converter (the thing that rotates image files) ignores EXIF rotation except in the special case that you tell it to rotate by the opposite of the EXIF rotation to fix the image.

Outside of that special case, the Image Converter always works on the actual pixel data, without any EXIF rotation added to the mix. If it rotates an image it'll clear the EXIF rotation data, which can mean that (in places where the EXIF rotation is used) the end result isn't what you'd expect as it's effectively two rotations instead of one.

There are three independent "use EXIF rotation" options for Thumbnails, the preview pane and the standalone viewer, but none affect the converter. Since the converter can be launched from all three of those places, and others, it wouldn't make sense for it to use any of their flags. It could have its own flag, but that could still be out of step with any of the others.

We might merge all the flags into a single setting, which probably makes sense anyway. But, even then, there are some complications to work out, like what happens if you convert an EXIF-rotated JPG into a BMP or some other format that doesn't contain EXIF, without asking for it to be rotated. Probably it should be rotated anyway, but the amount of cases to consider, code for, and test means it's complicated.

It's something we need to think about some more, and might change. It's definitely confusing if you see an image in one orientation in thumbnails (with EXIF rotation turned on for thumbnails) and then say "rotate 90 degrees" and you get a new thumbnail that isn't rotated 90 degrees from what you were looking at. And I don't think we need three separate EXIF rotation options, either; people probably either want it on or off everywhere. But there are a lot of interconnections to consider before we can change anything.

For your use-case, with the way things are currently, the best thing to do would be to either remove the rotation info or apply it and bake it into the image. Both can be lossless with some JPEGs, but removing the rotation info is the best option as it's always lossless. You can then rotate the image as needed.

(Of course, another option is to change the EXIF rotation value without touching the pixel data at all. That'll work as long as the image is displayed in things that use that value, and that's always lossless as well.)

The interactive image converter UI will also show you what's going to happen for any given operation, if in any doubt.


Thank you for this very detailed answer!
I understand that managing all cases is not easy.
For my case, I think the easiest is that I create 3 buttons:
rotation -90
rotation 90

Often only the first case will be necessary, because this need arises when my smartphone detects the rotation wrong.

Many thanks

1 Like