General advice on writing EXIF tags (Apache Commons Imaging/Sanselan)

Started by joakimk, May 21, 2016, 08:13:53 AM

Previous topic - Next topic

joakimk

I'm working on an android app (java project) where I want to read and write EXIF tags to jpegs on the device. I've found a library to handle the complex EXIF stuff, Apache Commons Imaging, previously called Sanselan.

The tags I want to write are EXIF_TAG_USER_COMMENT and EXIF_TAG_IMAGE_DESCRIPTION.
According to the documentation I could find, UserComment is of field type "undefined", whereas ImageDescription is of field type ASCII.

I realize this is neither a Java forum nor a Sanselan forum, but maybe someone can help me with some general advice on working with EXIF?

The Apache library should be quite serious stuff, doing all the hard work for me (I don't want to have to dive into binary data on my own) but I'm still worried my code might inadvertently corrupt image files and cause data loss.


joakimk

So, it's not an app to handle all EXIF tags, more of a way to annotate images with comments.

Phil Harvey

You don't need to worry about an EXIF editor corrupting a JPEG image -- that is hard to do.  But most EXIF editors will corrupt some proprietary makernote metadata -- you can't avoid that.

I haven't got any general advice that would be useful.  But come back if you have a more specific metadata question and I'll try to help.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

joakimk

Thanks for replying :)

In your info page, on Exif Tools, you write:

QuoteIt is possible for you to write nonsense into a file, which could cause other image readers to throw up their hands in despair and refuse to read the image. For this reason, it is best to always preserve the original copy of your image file. The "exiftool" script does this for you automatically by renaming the original file and always working on a copy.

But you're saying, a trusted exif editor (such as Apache Sanselan) should not mess up the image, regardless of what string the user might try to squeeze into the UserComment field? If the only worry is corrupting meta data, then I'll be less nervous about the app. As you understand, I don't want to risk data loss.
And also I don't want to have to create duplicate images all over the place. Is editing images in place generally frowned upon?

I do have some more specific questions on creating the "TiffOutputfields" (tags) for comment and image-description. I'll make a new post :)


Phil Harvey

That comment about image editors throwing their hands up in despair may be a result of unexpected metadata, but for JPEG images problems like this are usually always fixable because it is hard to corrupt the image itself (being well isolated from the metadata in this file format).

Editing images in place is what most people seem to do.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).