Java library for reading and writing IPTC metadata to JPEG and TIFF

前端 未结 6 560
感动是毒
感动是毒 2020-12-15 20:22


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 onl

相关标签:
6条回答
  • 2020-12-15 21:11

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

    0 讨论(0)
  • 2020-12-15 21:13

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

    0 讨论(0)
  • 2020-12-15 21:21

    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)

    0 讨论(0)
  • 2020-12-15 21:22

    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());
            }           
        }
    }
    
    0 讨论(0)
  • 2020-12-15 21:26

    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.

    0 讨论(0)
  • 2020-12-15 21:26

    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.

    0 讨论(0)
提交回复
热议问题