Did you know that all the jpegs from your digital camera contain a lot of extra information ?

We can easily retrieve some interesting information such as : title, equipment make, camera model, shutter speed, lens aperture, flash mode, date of picture, and much more ! these metadata "tags" are stored in a jpeg file to indicate various camera settings and picture taking conditions that occurred while creating the photo. several image file formats enable you to store metadata along with an image, such as jpeg, tiff and png.

Again GDI+ makes our lives easier, providing to us a function to get these information : getpropertyitem, stored in the gpimage class from _gdiplus.vcx .

Download and execute this file, and select an image from any digital camera, and you'll see all metadata stored in it.

On the first part of this code, i get the most common properties, from the gpimage class, like imagewidth, imageheight, horizontalresolution, verticalresolution and pixelformat.

On the rest i retrieve the metadata from the image file, using getpropertyidlist and getpropertyitem. it's important to notice that getpropertyidlist receives an array as a parameter, and returns that array populated with the metadata.

lcsource = getpict()
local loimage as gpimage of ffc/_gdiplus.vcx
loimage = newobject("gpimage", home() + "ffc/_gdiplus.vcx")

dimension rapropidlist(1)
local ncount, n, lctagname, lnprop, luprop

ncount = loimage.getpropertyidlist(@rapropidlist)
for n = 1 to ncount
lnprop = rapropidlist(n)
luprop = loimage.getpropertyitem(lnprop)

? transform(lnprop), transform(luprop)

It is possible to get some other really cool information from pictures. Take a look at the 2 last items in the picture, exiflightsource and exifflash. in both cases we have a zero value. check this table, to see what each possible value could mean :
tagid : 0x9208 (37384) - lightsource int16u exififd
1 = daylight
2 = fluorescent
3 = tungsten
4 = flash
9 = fine weather
10 = cloudy
11 = shade
12 = daylight fluorescent
13 = day white fluorescent
14 = cool white fluorescent
15 = white fluorescent
17 = standard light a
18 = standard light b
19 = standard light c
20 = d55
21 = d65
22 = d75
23 = d50
24 = iso studio tungsten
255 = other

tagid : 0x9209 (37385) - flash int16u exififd
0x0 = no flash
0x1 = fired
0x5 = fired, return not detected
0x7 = fired, return detected
0x9 = on
0xd = on, return not detected
0xf = on, return detected
0x10 = off
0x18 = auto, did not fire
0x19 = auto, fired
0x1d = auto, fired, return not detected
0x1f = auto, fired, return detected
0x20 = no flash function
0x41 = fired, red-eye reduction
0x45 = fired, red-eye reduction, return not detected
0x47 = fired, red-eye reduction, return detected
0x49 = on, red-eye reduction
0x4d = on, red-eye reduction, return not detected
0x4f = on, red-eye reduction, return detected
0x59 = auto, fired, red-eye reduction
0x5d = auto, fired, red-eye reduction, return not detected
0x5f = auto, fired, red-eye reduction, return detected

At this link you can find some other great information about metadata tags :


It is obviously possible to remove, change or set the metadata property items from images with gdi+ too, but for this task, it is necessary use some extra code, once _gdiplus.vcx doesn't bring this feature.


Comment added in 04/06/06

I wrote a much more detailed article on this subject to the universalthread magazine published in the april/2006 issue:
Saving and retrieving metadata information from your pictures with GDI+

 It's really worth to have a look there, where you will find a subclass for gpimage that permits to you to read, write or remove image tags.

1 comment:

  1. Versión en Español de este artículo en / Spanish version at http://www.portalfox.com/index.php?name=News&file=article&sid=2188