19


Does anyone know some opensource Java library for reading and writing IPTC metadata to JPEG and TIFF? Now I'm using Apache Sanselan. Unfortunately, it can only read IPTC, not write (http://commons.apache.org/sanselan/formatsupport.html).
Will be very grateful for your assistance.
Denis.

stormdb
  • 371
  • 1
  • 4
  • 13
  • 2
    There is a new choice [here](https://github.com/dragon66/icafe) - it can read, write IPTC, EXIF, ADOBE, ICCProfile, thumbnail etc – dragon66 Feb 05 '15 at 15:00

6 Answers6

5

This seems to be quite a old question but following is some helpful info:

reading of metadata such as EXIF,IPTC..etc can be done using Apache Commons Imaging(Formerly Sanselan) or Metadata Extractor(by drew noaks).

writing of metadata can be done using Apache Commons Imaging using following classes:

EXIF - ExifRewriter (http://commons.apache.org/proper/commons-imaging/apidocs/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.html)

IPTC - JpegIptcRewriter (http://commons.apache.org/proper/commons-imaging/apidocs/org/apache/commons/imaging/formats/jpeg/iptc/JpegIptcRewriter.html)

XMP - JpegXmpRewriter (http://commons.apache.org/proper/commons-imaging/apidocs/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpRewriter.html)

Chin
  • 19,717
  • 37
  • 107
  • 164
dev009
  • 755
  • 8
  • 13
5

Take a look at IIM4J. Use IIMWriter to write IPTC IIM tags into (jpeg) images.

schnatterer
  • 7,525
  • 7
  • 61
  • 80
Ben Asmussen
  • 964
  • 11
  • 15
4

The Apache Commons Imaging (formerly sanselan) has added support for writing IPTC metadata in the svn repo code for their next release. I have verified that this is so in the latest trunk code checked out from svn repo. The code seems stable so I am hoping a release is not too far away. For my project this is good enough.

Farrukh Najmi
  • 5,055
  • 3
  • 35
  • 54
  • I actually used this library in a project and it worked for me. You may found tests around (like here http://massapi.com/class/jp/JpegImageParser.html) – Duralumin Feb 19 '13 at 09:07
1

I've looked myself in the past but not found one. I would suggest looking at an open source project such as http://sourceforge.net/projects/image-tagger/ and see how they do it.

samblake
  • 1,517
  • 3
  • 16
  • 33
  • 1
    As I understand, Image-tagger uses ExifTool, which is written in Perl and needs Perl installed, right? If yes, then it is not suitable in my case, as my application should rely only on installed JRE. – stormdb Oct 06 '10 at 13:15
0

Another library with detailed documentation: https://docs.groupdocs.com/display/metadatajava, compliant with IIMV4.2

Jochen Haßfurter
  • 875
  • 2
  • 13
  • 27
0

For reading metadata I think you should have a look on "metadata-extractor" - an Open Source Project (Apache 2.0 licence) that develops a Java library for reading metadata from image files.

At the moment, this project can get access to the following metadata of images:

  • Exif
  • IPTC
  • XMP
  • JFIF / JFXX
  • ICC Profiles
  • Photoshop fields

The "metadata-extractor" is hosted at google code.

Here is a little straightforward code-example for the 2.4.0 version:

public void example() throws Exception {
    File jpegFile = new File("yourJpgFile.jpg");
    Metadata metadata = ImageMetadataReader.readMetadata(jpegFile);

    Iterator directory = metadata.getDirectoryIterator();
    while (directory.hasNext()) {
        Object tag = directory.next();
        if (tag instanceof ExifDirectory) {
            Iterator tags = ((ExifDirectory) tag).getTagIterator();
            while (tags.hasNext()) {
                System.out.println("EXIF: "+tags.next().toString());
            }
        } else if (tag instanceof IptcDirectory) {
            Iterator tags = ((IptcDirectory) tag).getTagIterator();
            while (tags.hasNext()) {
                System.out.println("IPTC: "+tags.next().toString());
            }
        } else if (tag instanceof JpegDirectory) {
            Iterator tags = ((JpegDirectory) tag).getTagIterator();
            while (tags.hasNext()) {
                System.out.println("JPEG: "+tags.next().toString());
            }
        } else {
            System.err.println(tag.getClass());
        }           
    }
}
Erik
  • 3,777
  • 21
  • 27
  • 4
    As I said, I need a library to read and **write** metadata. "Metadata-extractor" support only reading. – stormdb Sep 14 '11 at 05:26