Groups | Blog | Home
all groups > dotnet drawing api > september 2005 >

dotnet drawing api : Adding EXIF property to JPEG


Roger Beniot
9/28/2005 2:16:07 PM
I am trying to add EXIF properties to my JPEG pictures taken w/ a Canon
digital camera. The fields I want to add related to GPS data.

I have tried the suggestions listed at:
http://www.pixvillage.com/blogs/devblog/archive/2005/03/27/176.aspx

I have tried the following:
1) adding an image w/ PropertyItems to the assembly as a resource,
loading the resource, getting a property item, changing the property
item values, setting the property item to my Image and saving (using
the various implementations of Image.Save)

2) using reflection to get the PropertyItem constructor (yes not the
recommneded way but worth a try).

3) just loading an image w/ PropertyItems, getting a property item,
changing the property item values, setting the property item on my
image and saving the image.

4) also tried getting the JPEG image encoder and using it

In all cases the new property item is added but when I save the image
and then enumerator through the PropertyItems my new property is not
there.

I have tried saving as the original file, a different file name, etc.


Here is a very simple snip of what I've tried doing (C#):

Bitmap bmp = (Bitmap) Bitmap.FromFile(BASE_FILE);

PropertyItem pi = bmp.GetPropertyItem(0x10f);
pi.Id = 0x8825;
pi.Type = 2;
pi.Value = data;
pi.Len = data.Length;

bmp.SetPropertyItem(pi);

PropertyItem propItem = bmp.GetPropertyItem(0x8825);

bmp.Save(NEW_FILE2);


Thanks,
Roger
Roger Beniot
9/28/2005 6:45:49 PM
Michael... what documentation are you looking at (provide a link)?...

Everything I've read says it is supported:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdicpp/GDIPlus/GDIPlusreference/constants/imagepropertytagconstants/propertyitemdescriptions.asp

Plus it shouldn't make any difference... I should be able to add any
custom/non-supported property and have it correctly saved to the file.
I have tried adding a variety of different image properties (copyright,
description, artist, etc) and none of those save either.

-roger

[quoted text, click to view]
Michael Phillips, Jr.
9/28/2005 7:23:01 PM
The MSDN documentation states that PropertyTagGpsIFD is not exposed by gdi+
for public use.


[quoted text, click to view]

Michael Phillips, Jr.
9/29/2005 9:36:24 AM
I found this on the same page of the link that you posted:

PropertyTagGpsIFD

Offset to a block of GPS property items. Property items whose tags have the
prefix
PropertyTagGps are stored in the GPS block. The GPS property items are
defined in
the EXIF specification. GDI+ uses this tag to locate GPS information, but
GDI+
does not expose this tag for public use.

I have had sucess with PropertyTagThumbnailData.

I have not tried the GPS tags. I know they are specific for the image type
(e.g., gif, jpg, tiff, etc.). Some of the tags are written automatically by
the image decoder.

I suggest that you try to write a PropertyItem with a c++ test case.
The c++ interface is easier to use as it provides a constructor for
property items.

If it works, then use the interop code method described in the article
that you posted.


[quoted text, click to view]

AddThis Social Bookmark Button