多部分 tiff 和 EXIF 元数据

发布于 2024-08-05 12:58:04 字数 573 浏览 12 评论 0原文

在 tif 格式中,当您添加 EXIF 元数据时,它会创建一个新的 IFD(tif 目录)并将 exif 元数据存储为字段。因此,用单个图像和 exif 数据解析 tif 文件时很容易。但是您可以获得多部分 tiff,其中一个 tif 可以包含多个图像,问题是每个图像都可以有 EXIF 数据吗? 这是否会为每个图片元数据创建一个新的 IFD?

那么IFD的安排是怎样的呢?

tif规范没有详细说明,我知道当单个图像tif文件有EXIF数据时,EXIF数据有一个偏移字段,所以我可以跳转到该位置并自己进行解析,但是Java Sanselan库使我可以轻松访问 EXIF IFD 和字段,但是如果可以有多个 EXIF IFD(每个图像一个),那么库不会告诉我数据属于哪个图像。

如果在多部分 tif 文件中不能有超过 1 个 EXIF IFD,那么这将是微不足道的!换句话说: 我需要手动解析 exif 数据吗?因为我只需要执行此操作如果您可以将 EXIF 数据附加到多部分 tif 内的每个图像。

或者有人知道有一个好的 Linux 应用程序可以让我将 EXIF 数据添加到 tif 文件中,这样我就可以自己解决这个问题了吗?

In the tif format, when you add EXIF meta data it creates an new IFD (tif-direcory) and stores the exif metadata as fields. So when parsing a tif file with a single image and exif data is easy. But you can get multipart tiffs, where a tif can contain more then one image, the question is can each of these images have EXIF data?
Does this create a new IFD for each pictures metadata?

What is is the arrangement of the IFD's then?

The tif specification doesn't go into any detail, I know that when a single image tif file has EXIF data there is an offset field to the EXIF data, so I can jump to that location and do the parsing myself, but the Java Sanselan library gives me easy access to the EXIF IFD and fields, but if it is possible to multiple EXIF IFD's (one for each image) then the library doesn't tell me to which image the data belongs.

If you cannot have more then 1 EXIF IFD in a multipart tif file, then it'll be trivial! In other words:
Do I need to go to the effort of manually parsing the exif data? Because I only need to do this if you can attach EXIF data to each image inside a multipart tif.

Or does anyone know of a good Linux app that allows me to add EXIF data to tif files so I can figure it out for myself?

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

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

发布评论

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

评论(2

三月梨花 2024-08-12 12:58:04

回答您的问题:

这些图像中的每一个都可以有 EXIF 数据吗?这是否会为每个图片元数据创建一个新的 IFD?那么IFD的安排是怎样的呢?

是的,每个图像都可以有自己的 EXIF 数据。每个图像都与其自己的 IFD 相关,每个 EXIF 数据是相应图像 IFD 内的 SUB-IFD。

但是 Java Sanselan 库使我可以轻松访问 EXIF IFD 和字段,但如果可以使用多个 EXIF IFD(每个图像一个),那么该库不会告诉我数据属于哪个图像。

我从未使用过 Sanselan 及其后继者 Apache Imaging,所以我猜这里可能会发生两件事:首先,如果您确实可以将 EXIF 插入多页 TIFF,Sanselan 可能会默认选择多页 TIFF 的第一页;或者可能有一个参数,您可以使用 setWorkingPage(int page) 之类的方法在某处设置,这就是我正在使用“icafe" Java 图像库。

以下是有关当您需要添加 EXIF 元数据时 TIFF 图像内部发生的情况的更详细信息:

对于单页 TIFF,有一个“主”IFD,它指定有关其中包含的图像的所有信息。当需要EXIF数据时,一个名为“EXIF_SUB_IFD”的特殊标签被添加到主IFD中。该标签的值是相对于图像流开始的偏移地址。现在,如果我们跳转到偏移量指定的地址,我们实际上会找到一个“子”IFD,其结构与包含所有 EXIF 数据的“主”IFD 完全相同。

上述结构与目录树完全相同,因此命名为 IFD。然而,这里有一个微妙的区别:主 IFD 应包含实际图像数据,但 EXIF 子 IFD 不包含。事实上,还有一个GPS子IFD,它与EXIF子IFD并行,结构也相同。有趣的是 EXIF 数据可以存储在 TIFF 图像流内的任何位置(只要它不破坏目录和图像数据的其他部分)。

现在介绍多页 TIFF。这些页面可以相关,也可以不相关。每个页IFD的最后4个字节指向另一个IFD的偏移量。它们有时会聚集在一起作为可能来自扫描仪的“单个”文档。也就是说,每个页面本身就是一个“单”页 TIFF,它可以包含它自己的 EXIF 元数据,就像单页 TIFF 一样。

To answer your questions:

can each of these images have EXIF data? Does this create a new IFD for each pictures metadata? What is is the arrangement of the IFD's then?

Yes, each of these images can have it's own EXIF data. Each image is related to its own IFD and each EXIF data is a SUB-IFD inside the corresponding image IFD.

but the Java Sanselan library gives me easy access to the EXIF IFD and fields, but if it is possible to multiple EXIF IFD's (one for each image) then the library doesn't tell me to which image the data belongs.

I never used Sanselan and it's successor Apache Imaging so I guess there could be two things happening here: first, Sanselan may by default choose the first page for a multipage TIFF if you actually can insert EXIF to a multipage TIFF; or there might be a parameter which you can set somewhere with a method like setWorkingPage(int page) and this is what I am doing with "icafe" Java image library.

The following is a bit more detailed information as to what is happening inside a TIFF image when you need to add EXIF metadata:

For a single page TIFF, there is a "main" IFD which specifies all the information regarding the image contained there. When EXIF data is needed, an specially tag called "EXIF_SUB_IFD" is added to the main IFD. The value for this tag is an offset address with regards to the image stream start. Now if we jump to the address specified by the offset, we will actually find a "sub" IFD with exactly the same structure as the "main" IFD which contains all the EXIF data.

The above mentioned structure is exactly like a directory tree and hence the name IFD. There is however a subtle difference here: the main IFD should contain the actual image data but the EXIF sub-IFD doesn't. In fact, there is also a GPS sub-IFD which is in parallel with the EXIF sub-IFD and with the same structure as well. An interesting thing is the data for the EXIF can be stored anywhere inside the TIFF image stream (as long as it doesn't break other part of the directory and image data).

Now comes to the multipage TIFF. The pages can be related or not. The last 4 bytes of each page IFD points to the offset of another IFD. They are sometimes gathering together to serve as a "single" document which could be from a scanner. That said, each page is itself a "single" page TIFF which could contain it's own EXIF metadata just like a single page TIFF.

夏夜暖风 2024-08-12 12:58:04

您可能想查看 ExifTool。它非常适合我在 JPEG 上使用的情况,但我从未将它用于包含多个图像的 TIFF 文件。另请检查 ImageMagick,他有很多有用的工具。

You probably want to check out ExifTool. It works pretty well for what I use it on (JPEGs), but I've never used it with TIFF files containing multiple images. Also check ImageMagick, he has a ton of useful tools.

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