用于将 IPTC 元数据读取和写入 JPEG 和 TIFF 的 Java 库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3851665/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 03:40:40  来源:igfitidea点击:

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

javajpegtiffiptc

提问by Storm


Does anyone know some opensource Java library for reading and writingIPTC 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.


有谁知道一些用于IPTC 元数据读取和写入JPEG 和 TIFF 的开源 Java 库?现在我正在使用 Apache Sanselan。不幸的是,它只能读取 IPTC,不能写入 (http://commons.apache.org/sanselan/formatsupport.html)。
将非常感谢您的帮助。
丹尼斯。

回答by Ben Asmussen

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

看看IIM4J。使用IIMWriter写IPTC IIM标记为(JPEG)的图像。

回答by Farrukh Najmi

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.

Apache的百科全书成像(原sanselan)增加了在svn的代码编写IPTC元数据,他们的下一个版本的支持。我已经在从 svn repo 检出的最新主干代码中验证了这一点。代码看起来很稳定,所以我希望发布不会太远。对于我的项目来说,这已经足够了。

回答by dev009

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).

可以使用 Apache Commons Imaging(以前称为 Sanselan)或元数据提取器(by draw noaks)来读取 EXIF、IPTC 等元数据。

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

可以使用 Apache Commons Imaging 使用以下类来编写元数据:

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

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)

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)

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

回答by samblake

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.

我过去看过自己,但没有找到。我建议查看一个开源项目,例如http://sourceforge.net/projects/image-tagger/,看看他们是如何做到的。

回答by Erik

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.

对于读取元数据,我认为您应该查看“ metadata-extractor”——一个开源项目(Apache 2.0 许可证),它开发了一个用于从图像文件中读取元数据的 Java 库。

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

目前,该项目可以访问以下图像元数据:

  • Exif
  • IPTC
  • XMP
  • JFIF / JFXX
  • ICC Profiles
  • Photoshop fields
  • Exif
  • 国际贸易中心
  • XMP
  • JFIF / JFXX
  • ICC 配置文件
  • Photoshop 字段

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

元数据提取器”托管在google code

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

这是 2.4.0 版本的一个简单的代码示例:

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());
        }           
    }
}