使用元数据创建 jpeg 文件 [英] Creating a jpeg file with metadata

查看:31
本文介绍了使用元数据创建 jpeg 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Java 应用程序,它创建一个 BufferedImage 并将其以 JPEG 格式保存到磁盘.我真的很想为图像添加标题.为了防止图像被图像本身上的文本挤掉,如果我能将标题写入 JPEG 的元数据,那就太好了.

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.

我一直在到处寻找解决方案,但没有找到任何令人满意的.Sanselan 出现了很多,但我还没有想出如何正确使用它.我找到了修改现有元数据的示例,但我的文件不包含元数据,因为它们只是从 ImageIO.write() 或 Sanselan.writeImage() 创建的.

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

我发现了另一个帖子做我正在寻找的东西,但它是用 C# 编写的,我需要 Java.

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

任何帮助将不胜感激.

推荐答案

你要查看的包是javax.imageio.metadata

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

IIOMetaData 类(它有一个具体的 JPEG 子类)包含获取各种格式的元数据信息的方法,包括作为 XML DOM 树根节点.

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.

这篇关于使用元数据创建 jpeg 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆