From: Dan F. <da...@co...> - 2009-12-09 03:10:47
|
On Tue, Dec 01, 2009 at 01:07:19PM +0200, Thomas Andrews wrote: > Can anyone possibly share an example of how to use EXIF_TAG_USER_COMMENT The example program contrib/examples/write-exif.c shows generally how to create tags in a file, but it "cheats" and only writes tags that are created with default values in libexif. Changing the contents of an existing tag is trivial, but creating one from scratch is trickier. Unfortunately, EXIF_TAG_USER_COMMENT is one that isn't recognized by exif_entry_initialize() so it falls into the "trickier" category. You'll have to basically do this: Create an ExifEntry using exif_entry_new_mem, providing your own ExifMem allocator. You can't use exif_entry_new because you'll need access to the allocator to create space for the entry. Next, use that allocator to create a memory block and store the pointer in the "data" field of the ExifEntry you created. Fill in the rest of the public ExifEntry members describing the data (tag, format, etc.) and use exif_content_add_entry to attach the entry to an IFD. Finally, you can actually store the data you're interested in, namely the comment. Don't forget that the Exif standard specifies a specific format for EXIF_TAG_USER_COMMENT, including the character set used. I'll update the write-exif.c code when an example like this when I get a chance. >>> Dan -- http://www.MoveAnnouncer.com The web change of address service Let webmasters know that your web site has moved |