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

查看:245
本文介绍了使用元数据创建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().

I发现了另一个发布我做的事情我正在寻找,但它在C#,我需要Java。

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

任何帮助都将不胜感激。

Any help would be greatly appreciated.

推荐答案

您要查看的包是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天全站免登陆