ExifTool Forum

General => Metadata => Topic started by: joakimk on July 11, 2016, 03:58:48 PM

Title: Writing IPTC metadata (using Apache Commons Imaging) on Android
Post by: joakimk on July 11, 2016, 03:58:48 PM
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
Title: Re: Writing IPTC metadata (using Apache Commons Imaging) on Android
Post by: Phil Harvey on July 11, 2016, 04:26:33 PM
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
Title: Re: Writing IPTC metadata (using Apache Commons Imaging) on Android
Post by: joakimk on July 15, 2016, 02:56:43 PM
Thanks a lot! Such a boost to have the work checked out by the expert  :)