Thru VB.net/C# is there any way to read any metadata of off a JPEG to tell if the photo was taken in landscape or portrait?
I would assume a camera would need an accelerometer first of all to even tell what direction is up...correct? Assuming there is that kind of intelligence to detect the angle of tilt, how would I go about reading that info from a JPEG?
I found some samples online to read metadata with vb/.net not sure what to read to find the info i need.
Appreciate any pointers.....
The length of the longest side determines the orientation. For example, if the height of the image is longer than the width, it is a “portrait” format. Images where the width is longer are called “landscape.”
The EXIF orientation value is used by Photoshop and other photo editing software to automatically rotate photos, saving you a manual task.
EXIF (Exchangeable Image File Format) files store important data about photographs. Almost all digital cameras create these data files each time you snap a new picture. An EXIF file holds all the information about the image itself — such as the exposure level, where you took the photo, and any settings you used.
Yes, there's an EXIF tag that can store the orientation. Tag number 274, values are documented here. Sample code to read the tags from the JPEG data is available here.
A lot of digital cameras now have sensors within them to detect if the picture was taken in landscape or portrait mode. They then store this information in the header of the JPG. This data is known as EXIF.
Here is a pretty good tutorial on extracting the EXIF data from a JPG file. In addition to portrait/landscape info you can also extract (usually) the model/make of camera, lens settings, time/date etc.
http://www.codeproject.com/KB/graphics/NishExifReader.aspx
Would it be sufficient to simply compare the width of the JPG image to its height and if width > height, treat as landscape?
I have done this in C# before (although I can't remember the implementation details now but I remember it wasn't particularly difficult, a couple of lines of code only) for a website I worked on which required uploaded JPGs to be displayed within a frame (such as you might hang on your wall) and we needed to know whether to add the landscape or portrait version of the frame.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With