I took a photo with my iPhone of a package of bread, oriented in landscape. I then copy-pasted it to iOS-Mail (the only way to get un-resized photos sent via email), and emailed it to myself.
In the gmail preview, the image is oriented correctly. That is, the bread labels display text correctly.
When I downloaded the image to my desktop, I opened the image in Paint.NET, the image as rotated counter-clockwise 90 degrees.
I rotated the image in paint.net 90degrees clockwise, resized it, then saved it.
I emailed this photo to a friend, and in the gmail preview it now shows oriented 90CW, and the image preview in windows shows it as 90degrees counter-clockwise.
If I open the image, or upload the image, it is oriented properly.
So why are thumbnails oriented incorrectly, and how does software interpret the orientation to display the image?
Here are the thumbnails, windows on the left, gmail on the right. Same image.