Subject: 0.88: <Thumbnail and Image Orientation out of sync after Jpeg Lossless Rotate to 180>

XnView: MP 0.88 - 64 bit
OS: Windows 64bit

<Thumbnail and Image Orientation out of sync after Jpeg Lossless Rotate to 180.>

Effect: <Thumbnail and Image Orientation out of sync >

To reproduce:
1. Consider a Jpeg having a rotation of bottom-right (3) in Orientation, both for Image and Thumbnail
2. Browser->Jpeg lossless transformation->Rotate 180 (or make a Reset EXIF Orientation Field)
3.
Actual behaviour (bug): <Current wrong behaviour of XnView>
The EXIF Orientation tag for Image is set to top-left (1) , but the EXIF Orientation tag for Thumbnail remains bottom-right (3)

Expected behavior:
I would expect the Orientation for the Thumbnail to be synced to the Orientation for the Image (like it happens when rotating to 90).
After this operation, even using Metadata->EXIF Thumbnail Rebuild does not change the Thumbnail Orientation tag to match the orientation of the image.
I am not sure where the Orientation tag for the Thumbnail is used so I cannot see implications further.

Just to make it clear... the picture and the thumbnail are not displayed with opposite orientation after the operation, but the Thumbnail Orientation flag and the Image Orientation flag do not match after the operation.
Actually the same thing happens on other operations like resize.

Tested with 0.91 beta 4.
I had an issue with this thumb orientation issue for a long time and my workflow has been to switch OFF Settings, General, tab General, "Rotate images according to EXIF orientation tag" before every time I wanted to adjust portrait images (adjusting levels mostly).
I was hoping that this issue would be fixed now, but unfortunately it seems still the same..

First tested with 0.90
Take a portrait image, rotate with JPEG lossless transformations (or just the rotate buttons in the toolbar). Picture and thumb are rotated.
Edit a portrait image, change levels, Save with overwrite, the picture is portrait, the thumb is rotated to landscape.
I did not check exif orientation tags, because in my files there is no thumb orientation tag, just picture orientation.

Then tested with 0.91 beta 4
The behavior is exactly the same. Lossless rotate works, thumb and image are rotated, edit and save leaves us with a correct orriented image but wrong oriented thumbail.
One thing I have noticed is that portrait pictures are saved as portrait files, like in Photoshop, and not as landscape files with a portrait orientation bit.

First tested with 0.90
Take a portrait image, rotate with JPEG lossless transformations (or just the rotate buttons in the toolbar). Picture and thumb are rotated.
Edit a portrait image, change levels, Save with overwrite, the picture is portrait, the thumb is rotated to landscape.
I did not check exif orientation tags, because in my files there is no thumb orientation tag, just picture orientation.

By the way, to make shure that it is not a thumbnail cache problem, after saving the modified portrait file I closed XnViewMP and deleted Thumb.db and XnView.db, then started XnViewMP again (thumbnail was landscape, View mode still portrait.

So that made met test with a fresh download on my test VM, so without my xnview.ini.
And then I can't reproduce eighter.
Then I remembered that I always have "Rebuild embedded EXIF thumbnail" unchecked in Format settings, Write tab, JPEG tab.
Tested by unchecking that setting in the test VM, then I can reproduce.

I prefer not rebuilding embedded thumbnails, only do that in special occasions.

So now is the question: how are portrait pictures saved after modifying?
I notice that before saving the size of my sample picture is 3744x5616, after saving it is 5616x3744, so height and width are flipped, and the EXIF orientation tag is reset from 8 to 1.
I remember that behavior from Photoshop.
Is that a general behavior when portrait pictures are modified and saved?
I believe not, because when I modify a portrait picture with first unchecking Settings, General, Rotate images according to EXIF orientation tag, and then save, the thumbnail and image orientation stay the same (that is my current procedure).
So my current procedure is:
1. Uncheck Rotate images according to EXIF orientation tag.
2. Close XnViewMP.
3. Start XnViewMP, modify the portrait picture with pain in my neck, save the picture.
4. Check Rotate images according to EXIF orientation tag again.
5. Close and start XnViewMP again.
(cloosing and starting XnViewMP between changing the setting is necessary because the thumbnail orientation does not refresh)

So, I have no idea if you can fix this for users who have "Rebuild embedded EXIF thumbnail" unchecked.