How do I know if a photograph was taken in a landscape or in a portrait? Orientation of metadata in JPEG.NET format

Thru VB.net/C# is there any way to read any JPEG metadata to see if the photo was taken in a landscape or portrait?

I would suggest that an accelerometer is required for the camera, first of all, to say in which direction up ... right? Assuming that there is such intelligence to determine the angle of inclination, how will I read this information from JPEG?

I found several samples on the Internet to read metadata from vb / .net, not sure what to read to find the information I need.

Appreciate any pointers .....

+4
source share
3 answers

Yes, there is an EXIF โ€‹โ€‹tag that can preserve orientation. Tag number 274, the values โ€‹โ€‹are described here . Sample code for reading tags from JPEG data is available here .

+6
source

Many digital cameras now have sensors to determine if the picture was taken in landscape or portrait mode. They then store this information in the JPG header. This data is known as EXIF.

Here is a pretty good tutorial on extracting EXIF โ€‹โ€‹data from a JPG file. In addition to portrait / landscape information, you can also extract (usually) a model / make a camera, lens settings, time / date, etc.

http://www.codeproject.com/KB/graphics/NishExifReader.aspx

+2
source

Is it enough to simply compare the width of a JPG image with its height and width> height, to consider it as a landscape?

I used to do this in C # (although I canโ€™t remember the implementation details now, but I remember that it wasnโ€™t particularly difficult, just a few lines of code) for the website I was working on and which was supposed to load JPG (for example, you can hang it on the wall), and we needed to know whether to add a landscape or portrait version of the frame.

+1
source

Source: https://habr.com/ru/post/1306377/


All Articles