access to jpeg properties

G

Guest

I am trying to programmatically access to the properties of a picture file
(jpg). These properties are available in Explorer by right
clicking->selecting "properties"->"Summary" tab. Examples of these properties
are: width, height, Date picture Taken, etc.

Unfortunately, I cannot find a way to access them from C#.NET.

Thansk for your help.

Val
 
S

Steven Nagy

The information you need can be obtained from 2 different sources.
General file information such as creation and modification dates can be
accessed through the FileInfo class in System.IO

To get image height and so on, you can create an instance of the Image
object.
Eg.
Image i = Image.FromFile("asdas.jpg");
int Height = i.Height;

There might be a way to invoke to get the same stuff that the OS
returns, but I don't know much about those methods myself.

SN
 
B

Brant Estes

Windows stores this information in the EXIF information in the image.
You can access these properties by loading up the image into a
System.Drawing.Image and searching through the PropertyItems
collection.

Each item in the PropertyItems collection has a key/value combination.
The key coincides with a number set forth by the EXIF standard, and
maps to various information about the image (exposure, shutter speed,
etc).

Microsoft uses this to store additional information which shows up on
the properties of the image in Windows. The keys which correlate with
these are:

Title = 0x9C9B
Comments = 0x9C9C
Keywords = 0x9C9D
Subject = 0x9C9E

The values are stored as Unicode strings in the Value property of the
PropertyItem, and can be extracted using the static
System.Text.ASCIIEncoding.Unicode.GetString() method.

Hope this helps!

Brant Estes
Magenic Technologies
 
B

Brant Estes

One more thing, only _some_ of the properties are stored as Unicode
strings. Others are encoded differently, and will need additional
processing, because they represent things like rational numbers, times,
etc. Reading up on the EXIF standard will help to determine how to
parse this type of information.

The PropertyInfo class also exposes a Type property. The values for
this map to what data is in there, and this may help you to determine
how to process it:

1 = Unicode string, byte, or raw byte array
2 = ASCII string
3 = Short
4 = UInt32 (mainly used for lookups, orientation, etc)
5 = Rational (such as 3/4) Its expressed as two longs
7 = Undefined/Proprietary (typically a byte)
9 = Signed Long. (a 32-bit signed integer (2's complement notation))
10 = Signed Rational (Its expressed as two signed longs)

Some of the more interesting information and their keys are:

DateTaken = 0x9003
ExposureBias = 0x9204
MaxAperture = 0x9205
LightSource = 0x9208
Flash = 0x9209
FocalLength = 0x920A
FNumber = 0x829D
ExposureTime = 0x829A
MeteringMode = 0x9207

Have fun!

Brant Estes
Magenic Technologies
 
O

Otis Mukinfus

I am trying to programmatically access to the properties of a picture file
(jpg). These properties are available in Explorer by right
clicking->selecting "properties"->"Summary" tab. Examples of these properties
are: width, height, Date picture Taken, etc.

Unfortunately, I cannot find a way to access them from C#.NET.

Thansk for your help.

Val

Take a look at the EXIF Library menu item at this URL.
http://www.otismukinfus.com/vault/vault.htm

Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top