简体   繁体   English

使用元数据创建jpeg文件

[英]Creating a jpeg file with metadata

I have a Java application that creates a BufferedImage and saves it to disk as a JPEG. 我有一个Java应用程序,它创建BufferedImage并将其作为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. 为了防止图像被图像本身上的文本挤占,最好将标题写到JPEG的元数据中。

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. Sanselan出现了很多,但是我还没有弄清楚如何正确使用它。 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(). 我找到了修改现有元数据的示例,但是我的文件不包含元数据,因为它们只是从ImageIO.write()或Sanselan.writeImage()创建的。

I found another post that does what I'm looking for, but it's in C# and I need Java. 我发现了另一篇可以满足我需求的文章 ,但是它在C#中,我需要Java。

Any help would be greatly appreciated. 任何帮助将不胜感激。

the package you want to look at is javax.imageio.metadata 您要查看的包是javax.imageio.metadata

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. IIOMetaData类(具有JPEG的具体子类)包含用于获取各种格式(包括作为XML DOM树根节点)的元数据信息的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM