1

I have a Java application that creates a BufferedImage and saves it to disk as a JPEG. I'd really like to add a caption to the image. To prevent the image from getting crowded out by text on the image itself, it'd be great if I could write the caption to the JPEG's metadata.

I've been searching all over the place for a solution, but haven't found anything satisfactory. Sanselan comes up a lot, but I haven't figured out how to use it properly. I found examples that modify existing metadata, but my files don't contain metadata as they are simply created from ImageIO.write() or Sanselan.writeImage().

I found another post that does what I'm looking for, but it's in C# and I need Java.

Any help would be greatly appreciated.

Community
  • 1
  • 1
Ryan
  • 4,517
  • 7
  • 30
  • 34

1 Answers1

3

the package you want to look at is javax.imageio.metadata

The IIOMetaData class (which has a concrete subclass for JPEG) contains methods to get metadata information in various formats, including as an XML DOM tree root node.

robert_x44
  • 9,224
  • 1
  • 32
  • 37
  • 1
    oh, and you can write a tree back with setFromTree(), which is in retrospect what you were really asking :)P – robert_x44 Oct 11 '10 at 19:42