Is there a way to keep the original orientation of an image?
Hello Stephan,
If an image has been rotated by a specific software, it is likely that its EXIF orientation would be changed in order to rotate the image, without changing the image data. If this image is opened in Windows Photo Viewer it will be displayed correctly, since it will detect the EXIF orientation, however this is not the case while using the PictureBox or the UltraPictureBox.
I have created a method called ChangeImageBasedOnExifOrientation, it detects if the image has an EXIF orientation, based on it, the image is rotated using the RotateFlipType enumeration.
I am attaching a small sample application that demonstrates what I have explained above. In it I am using two different images – Tree and Tree_Modified. The Tree_Modified image is the same image, but it is rotated by 90 degrees. I am using an OpenFileDialog to get the image and then before assigning it to the UltaPictureBox the ChangeImageBasedOnExifOrientation.
Please test the sample on your side and let me know if you have any questions.
Regards, Ivan Kitanov
UltraPictureBoxOrientation.zip
Thank you for help and advice, Ivan! It was useful for me.
Thanks Ivan, I'll try it. Interesting this is if I reduce the image 50% down from 2268 x 4032 to 1134 x 2016 it works fine. I am reducing the size when bringing the image in by looking at the width and height but when the image is a high resolution the code is reading the height and width backwards. It sets the height of 4032 and as the width.
My next question, is there a limitation or a max size the picture box can handle or is there a way to increase it?