Multipage tiff and EXIF ​​metadata

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

What is IFD location?

The tif spec doesn't go into details, I know that when one image tif file has EXIF ​​data, there is an offset field in the EXIF ​​data, so I can go to that location and parse it myself, but the Sanselan Java library gives me easy access to EXIF ​​IFDs and fields, but if multiple EXIF ​​IFDs are possible (one for each image), then the library doesn't tell me which image this data belongs to.

If you cannot have more than 1 EXIF ​​IFD in a multi-page tif file then it would be trivial! In other words: Do I need to make an effort to manually parse the exif data? Because I only need to do this if you can attach EXIF ​​data to each image inside a multi-page 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?

+2


source to share


2 answers


To answer your questions:

Can each of these images have EXIF ​​data? Does this create a new IFD for each image metadata? What is IFD location?

Yes, each of these images can have their own EXIF ​​data. Each image is associated with its own IFD, and each EXIF ​​data is SUB-IFD within the corresponding IFD of the image.

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

I have never used Sanselan and its successor Apache Imaging, so I guess there might be two things here: first, Sanselan can by default choose the first page for a multi-page TIFF if you can actually embed EXIF ​​in a multi-page TIFF; or there might be a parameter that you can set somewhere with a method such as setWorkingPage(int page)

and this is what I do with icafe "Java Image Library.



See below for more details on what happens inside a TIFF image when you need to add EXIF ​​metadata:

For a single page TIFF, there is a "master" IFD that defines all the information about the image it contains. When EXIF ​​data is needed, a special tag called "EXIF_SUB_IFD" is added to the main IFD. The value for this tag is the offset address from the start of the image stream. Now, if we go to the address indicated by the offset, we actually find a "sub" IFD with exactly the same structure as the "main" IFD, which contains all the EXIF ​​data.

The above structure is exactly like the directory tree and hence the IFD name. However, there is a subtle difference here: the main IFD should contain the actual image data, but the sub-IFD EXIF ​​does not. In fact, there is also a GPS sub-IFD that is parallel to the IFIF sub-IFD and with the same structure. Interestingly, data for EXIF ​​can be stored anywhere within the TIFF image stream (as long as it doesn't break another part of the directory and image data).

Now comes multipage TIFF. Pages can be linked or not. The last 4 bytes of the IFD of each page indicate the offset of the other IFD. They sometimes come together to serve as the "only" document that can be from a scanner. However, each page is itself a "single" TIFF page, which can contain its own EXIF ​​metadata like a single page TIFF.

+1


source


You probably want to check out ExifTool . It works very well for the fact that I use it (JPEG), but I have never used it with TIFF files containing multiple images. Also check out ImageMagick, it has tons of useful tools.



0


source







All Articles