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

发布于 2024-09-26 09:58:43 字数 363 浏览 5 评论 0 原文


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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

只想待在家 2024-10-03 09:58:43

这似乎是一个相当老的问题,但以下是一些有用的信息:

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

元数据的写入可以使用 Apache Commons Imaging 使用以下类来完成:

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)

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)

太阳男子 2024-10-03 09:58:43

查看 IIM4J。使用 IIMWriter 将 IPTC IIM 标签写入 (jpeg) 图像。

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

虐人心 2024-10-03 09:58:43

Apache Commons Imaging(以前称为 sanselan) 添加了对在 svn 存储库代码中写入 IPTC 元数据的支持,以供其使用下一个版本。我已经在从 svn repo 签出的最新主干代码中验证了这一点。代码看起来很稳定,所以我希望发布不会太远。对于我的项目来说这已经足够好了。

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.

時窥 2024-10-03 09:58:43

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

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.

温柔戏命师 2024-10-03 09:58:43

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

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

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

metadata-extractor" 托管于 Google 代码

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

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());
        }           
    }
}
温折酒 2024-10-03 09:58:43

另一个包含详细文档的库:https://docs.groupdocs.com/display/metadatajava,符合IIMV4.2

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文