Writing IPTC metadata (using Apache Commons Imaging) on Android

Started by joakimk, July 11, 2016, 03:58:48 PM

Previous topic - Next topic

joakimk

I'm playing around with an Android app to write JPEG metadata, using the Apache Commons Imaging library (previously called Sanselan).
This has support for both EXIF and IPTC. The EXIF part I'm essentially following this sample code:
https://apache.googlesource.com/sanselan/+/e3b28b1c83ed93ce763e59afbbf5d2dba86901fb/src/test/java/org/apache/commons/sanselan/examples/WriteExifMetadataExample.java

For IPTC, I found this sample code:
https://github.com/apache/sanselan/blob/trunk/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcUpdateTest.java

Next, I found this sample code where EXIF and IPTC metadata are combined, in one go (write):
http://mail-archives.apache.org/mod_mbox/incubator-sanselan-dev/200811.mbox/%3C5609ED95-E659-4DE7-9EA0-EA2DBB76EE98@thebluncks.com%3E

I extended my code for writing "JpegImageMetadata" (EXIF) with a subsequent stage of modifying the "JpegPhotoshopMetadata" (IPTC) in the same outputstream (target file).
It seems to work; doesn't crash, and successfully writes both the EXIF:ImageDescription and IPTC:Caption-Abstract (as well as IPTC:City and IPTC:Credit, just to play around).

Using this example IPTC image, I've modified the tags as described above. Can someone perhaps have a look at the resulting JPEG, as attached, and see if something smells? :)
https://iptc.org/std/photometadata/examples/IPTC-PhotometadataRef-Std2014_large.jpg

Phil Harvey

Good job.

You can see the EXIF structure with the -htmlDump option.

The only problem is a very minor one:  According to the TIFF spec all values should be word-aligned.  Also, some dumb EXIF readers may not like it that you didn't put IFD0 at byte 8, but it is perfectly according to the spec the way you have done it.

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

joakimk

Thanks a lot! Such a boost to have the work checked out by the expert  :)