使用Java从tif文件中提取IPTC/EXIF数据
我正在开发的系统具有使用 com.drew.metadata 包从 JPEG 文件中提取元数据的功能。 http://www.drewnoakes.com/code/exif/ 但是仅限于JPEG 文件,现在客户询问如何从 TIF 以及可能的其他图像格式中提取 IPTC。
有谁知道与 Drew Noakes 类似的 API,可以从 TIF 中提取 IPTC?
理想情况下,这将是一种纯 Java 方法,例如 com.drew.metadata 方法。
The system I'm working on has a feature to extract metadata from JPEG files using the com.drew.metadata
package. http://www.drewnoakes.com/code/exif/ However that is limited to JPEG files, and now a customer has asked about extracting IPTC from TIF, and possibly other image formats.
Does anyone know about similar APIs to Drew Noakes one, that can extract IPTC from TIF?
Ideally this would be a pure Java approach like the com.drew.metadata
one.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
这是一个老问题了。现在,我的元数据提取器库支持 TIFF 文件,以及 JPEG、WebP、PSD、PNG、GIF、BMP、ICO、PCX 和许多相机原始格式。
该项目最近转移到 GitHub:
https://github.com/drewnoakes/metadata-extractor
并且可通过 Maven 获取:
http://search.maven.org/#search%7Cga% 7C1%7C德鲁诺克斯
This is an old question. Nowadays my
metadata-extractor
library supports TIFF files, as well as JPEG, WebP, PSD, PNG, GIF, BMP, ICO, PCX and many camera raw formats.The project recently moved to GitHub:
https://github.com/drewnoakes/metadata-extractor
And is available via Maven:
http://search.maven.org/#search%7Cga%7C1%7Cdrewnoakes
我最近花了一些时间编写 icafe Java 图像库的元数据操作部分,并使其能够插入和提取元数据类型,如 EXIF、IPTC、PHOTOSHOP、ICC_Profile、缩略图等。有些功能比其他功能更好,但它们都相对工作得很好。所有元数据读取都有一个通用接口,如下所示:
如果我们从项目的“images”目录中传递图像“iptc.tif”作为参数,我们将得到以下信息:
上面的代码适用于 JPEG 和TIFF 类似。它会自动检测图像类型并委托给相应的代码来完成工作。
注意:TIFF 文件中可能有多个位置包含 IPTC 数据。一个是 RichTiffIPTC 标签,另一个隐藏在 Photoshop 标签内。目前icafe只保留一份IPTC数据。如果带有 IPTC 数据的 Photoshop 标签和 RichTiffIPTC 标签同时存在,它将保留 RichTiffIPTC 数据。否则,无论存在哪个标签,它都会保留该标签的 IPTC 数据。保存两个地方的数据没有问题。当前的实现使用将元数据类型键映射到唯一元数据的映射。因此它只保留一个唯一的元数据实例。
更新: icafe 现在可以合并来自 RichTiffIPTC 和 Photoshop IRB 的 IPTC 数据删除重复项。
更新2: ICAFE 中所有元数据类型的基类 - Metadata 现在实现了 Iterable 接口,因此用户现在可以迭代 MetadataEntry 的集合。 MetadataEntry 本身是使用复合模式创建的,因此 MetadataEntry 可以包含其他 MetadataEntry 的集合。每个 MetadataEntry 包含一个键和一个值对。这种设计允许元数据条目的树结构遍历。
I spent some time recently coding the metadata manipulation part of icafe Java image library and make it able to insert and extract metadata types like EXIF, IPTC, PHOTOSHOP, ICC_Profile, thumbnail etc. Some functions are better than others, but they all relatively work fine. There is a common interface for all the metadata reading shown below:
If we pass the image "iptc.tif" from the "images" directory of the project as the argument, we will get the following information:
The above code works for JPEG and TIFF alike. It automatically detects the image type and delegate to corresponding code to do the work.
NOTE: there could be more than one places in a TIFF file which contains IPTC data. One is RichTiffIPTC tag, the other is buried inside a Photoshop tag. Currently, icafe only keeps one IPTC data. If both Photoshop tag with IPTC data and a RichTiffIPTC tag exist, it will keep the RichTiffIPTC data. Otherwise, whichever tag exists, it will keep IPTC data from that tag. There is no problem keeping data from both places. Current implementation using a map mapping a metadata type key to a unique metadata. So it only keeps one unique metadata instance.
Update: icafe can now combine IPTC data from both RichTiffIPTC and Photoshop IRB and remove duplicates.
Update2: The base class of all the metadata types in ICAFE - Metadata now implements Iterable interface so the user can now iterate through a collection of MetadataEntry. MetadataEntry itself is created using composite pattern so a MetadataEntry can contain a collection of other MetadataEntry. Each MetadataEntry contains a key and a value pair. This design allow for a tree structure traversal of the metadata entries.
这里有一个使用
imageio
lib 访问 IPTC 的好例子http://www.barregren.se/blog/how-read-exif-and-iptc-java-image-io-api
不幸的是,您'仍然需要自己处理一些工作。
There's a good example here of using the
imageio
lib to access IPTC herehttp://www.barregren.se/blog/how-read-exif-and-iptc-java-image-i-o-api
Unfortunately, you'll still have to handle some of the work yourself.
如果您找不到纯 Java 实现,您可以考虑使用 ImageMagick 的 Java 绑定 (JMagick )。这将允许多种不同的可能的输出格式。
If you cannot find a pure Java implementation, you could consider using the Java bindings to ImageMagick (JMagick). That would allow for a plethora of different possible output formats.