1

I am looking at examples of icafe library https://github.com/dragon66/icafe to see how to manipulate the image metadata but I can't find any examples.

I am trying to add a field to the exif metadata like Description and add some sample text to that field.

Also, from what I have found I can't seem to tell whether icafe will work on image input stream or does it need an absolute path to a file stored on the disk?

dragon66
  • 2,645
  • 2
  • 21
  • 43
Anthony
  • 33,838
  • 42
  • 169
  • 278
  • I just realized I missed the part related to metadata manipulation in the wiki page of icafe as another user sent an email asking similar question as this one. – dragon66 Oct 30 '16 at 00:24

1 Answers1

0

Although there is no example on the wiki page, there is actually a detailed example on how to manipulate metadata which can be found in the source code package com.icafe4j.test. The name for the class is TestMetadata which shows you how to insert different metadata like EXIF, IPTC, XMP, Comment, Thumbnail etc.

ICAFE works with InputStream and OutputStream. So it doesn't matter if it comes from a local file or not as long as it is an InputStream. If you only want to add some comments, you can simply do something like this:

FileInputStream fin = new FileInputStream("input.png");
FileOutputStream fout = new FileOutputStream("comment-inserted.png");

Metadata.insertComments(fin, fout, Arrays.asList("Comment1", "Comment2"));

The above code works for common image formats like JPEG, TIFF, PNG, GIF etc equally as long as the format supports certain metadata.

If you want to work with Exif, you can use:

Metadata.insertExif(InputStream fin, OutputStream fout, Exif exif, boolean upate);

which also has a parameter "update" to control whether or not you want to keep the original Exif data if present. Details on how to create Exif instance can be found from the same example.

dragon66
  • 2,645
  • 2
  • 21
  • 43