I need to read any image's orientation in .net. I am trying to read this information through extracting orientation property from Exif data.
public enum ExifOrientations
{
Unknown = 0,
TopLeft = 1,
TopRight = 2,
BottomRight = 3,
BottomLeft = 4,
LeftTop = 5,
RightTop = 6,
RightBottom = 7,
LeftBottom = 8,
}
// Return the image's orientation.
public static ExifOrientations ImageOrientation(Image img)
{
const int OrientationId = 0x0112;
// Get the index of the orientation property.
int orientation_index =
Array.IndexOf(img.PropertyIdList, OrientationId);
// If there is no such property, return Unknown.
if (orientation_index < 0) return ExifOrientations.Unknown;
var orientationValue = img.GetPropertyItem(OrientationId).Value[0];
// Return the orientation value.
return (ExifOrientations)
img.GetPropertyItem(OrientationId).Value[0];
}
But I found many images don't have EXIF data for orientation, in that case, what is the best way to get an image's orientation.
This image doesn't have any orientation data. But below picture I think gives wrong orientation data or I misunderstood.
How is this image's orientation can be "TopLeft" as it's determined by the above code?
I need to know is there any other way of getting the image's orientation data if EXIF data doesn't exist.