Try something along these lines:
private static void rewriteUserComment(String fileIn, String fileOut)
throws Exception {
TiffImageMetadata exif;
IImageMetadata meta = Imaging.getMetadata(new File(fileIn));
if (meta instanceof JpegImageMetadata) {
exif = ((JpegImageMetadata)meta).getExif();
} else if (meta instanceof TiffImageMetadata) {
exif = (TiffImageMetadata)meta;
} else {
return;
}
TiffOutputSet outputSet = exif.getOutputSet();
TiffOutputDirectory exifDir =
outputSet.findDirectory(TiffDirectoryConstants.DIRECTORY_TYPE_EXIF);
exifDir.removeField(ExifTagConstants.EXIF_TAG_USER_COMMENT);
exifDir.add(ExifTagConstants.EXIF_TAG_USER_COMMENT, "my very
own comment with " + '\u041F');
ExifRewriter rewriter = new ExifRewriter();
FileOutputStream fos = null;
try {
fos = new FileOutputStream(new File(fileOut));
rewriter.updateExifMetadataLossy(new File(fileIn), fos, outputSet);
} finally {
if (fos != null) {
fos.close();
}
}
}
Regards
Damjan
On Wed, Jan 16, 2013 at 8:52 AM, Clement Levallois
<[email protected]> wrote:
> Hi,
>
> I posted this question on StackOverflow but it might get more attention
> here:
>
> http://stackoverflow.com/questions/14341054/writing-custom-metadata-fields-to-jpeg-with-apache-commons-imaging
>
> Basically, I can't find a working example to write on a EXIF tag with
> Commons Imaging. Any help would be appreciated!
>
> Best,
>
> Clement
>
> --------------------------------------------
> Clement Levallois, PhD
> Erasmus University Rotterdam
> The Netherlands
>
> pro website<http://www.erim.eur.nl/ERIM/People/Person_Details?p_aff_id=4321>
> / personal website <http://www.clementlevallois.net/>
>
> twitter and skype: @seinecle
> Discover the NESSHI project: http://www.nesshi.eu
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]