Extracting EXIF from a jpg

SharkBait
06-28-2006, 04:54 PM
Hello,

I am wondering if anyone has any samples about extracting the EXIF information from a jpg.

I've been looking around and there seems to be alot of information but I am troubled as to where I should start.

Pretty much I want to select an image and spit outs its EXIF tags. I believe they are stored in bytes and I would have to run through a long list and decode each tag to see what the value is.

Does this make sense?

Just a small personal project for home. I would eventually have it change the filenames of all images in a directory to the date the photo was taken.

So..

IMG102 becomes 20061208121256 or even something more simple than that. That image would of course been taken August 12, 2006 at 12:12:56.

It would help catalogue alot of images that are taken and make it easier to find them down the road after they have been burnt to CD/DVD :)

MikeJ
06-28-2006, 05:20 PM
There's an article on this in MSDN:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnhcvb04/html/vb04b15.asp

SharkBait
06-28-2006, 06:10 PM
I thought I saw that article.. couldnt remember where I saw it.

Thanks helps alot.

SharkBait
06-28-2006, 06:35 PM
In the MSDN sample I am unclear how the .toString("x") does

I understand that .toString() returns a human readable value, but what does the ("x") do?

So what the code looks like is:


' Import System.Drawing.Imaging

Dim MyInfo as Image = New Bitmap(OpenFileDialog1.FileName)
Dim AProp as PropertyItem

For Each AProp In MyInfo.PropertyItems
Try
Select Case AProp.Id.ToString("x")
Case "10e" 'Image name
ts = Trim(Replace(encoding.GetString(AProp.Value), Chr(0), ""))
Case "a002" ' Width
W = BitConverter.ToInt32(AProp.Value, 0)
Case "a003" ' Height
H = BitConverter.ToInt32(AProp.Value, 0)
End Select
Catch ex as Exception
End Try
Next


Also wondering why my jpgs arent returning a W(idth) or H(eight). When I use Windows and look at the properties->Summary->Advanced it shows me the Width and Height in pixels.

MyDevAccount
07-31-2006, 01:26 AM
In the MSDN sample I am unclear how the .toString("x") does

I understand that .toString() returns a human readable value, but what does the ("x") do?

It converts it to it's hexadecimal value. That's what EXIF uses.

Also wondering why my jpgs arent returning a W(idth) or H(eight). When I use Windows and look at the properties->Summary->Advanced it shows me the Width and Height in pixels.

Windows Properties->Summary->Advanced probably uses the JPEG header data to get the width and height. Just try to make sure you've actually got the proper EXIF data embedded in your JPEGs when testing.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum