My example tiff has 593 images and it seems not optimal to parse output of this command
exiftool -G1 -a -e my-image.tif
I could grep and count fields but there must be a better way or some shell guru logic to do better.
I know that there are `ImageMagick` and `libtiff` (`tiffinfo`) but I want to know.
I found this https://exiftool.org/forum/index.php?topic=3062.0
I want something like this which works for PDF files:
exiftool -fast -n -T -PageCount -ext pdf -q my-file.pdf
Here is one output:
❯ exiftool -ver
12.30
❯ exiftool -G1 -a -e vode-st-615378.tif | head -n50
Deep recursion on subroutine "Image::ExifTool::ProcessDirectory" at /usr/share/perl5/vendor_perl/Image/ExifTool/Exif.pm line 6611.
Deep recursion on subroutine "Image::ExifTool::Exif::ProcessExif" at /usr/share/perl5/vendor_perl/Image/ExifTool.pm line 7783.
[ExifTool] ExifTool Version Number : 12.30
[System] File Name : vode-st-615378.tif
[System] Directory : .
[System] File Size : 17 MiB
[System] File Modification Date/Time : 2022:01:24 13:41:28+01:00
[System] File Access Date/Time : 2022:01:24 13:41:22+01:00
[System] File Inode Change Date/Time : 2022:01:24 13:41:52+01:00
[System] File Permissions : -rw-r--r--
[File] File Type : TIFF
[File] File Type Extension : tif
[File] MIME Type : image/tiff
[File] Exif Byte Order : Little-endian (Intel, II)
[IFD0] Subfile Type : Full-resolution image
[IFD0] Image Width : 1632
[IFD0] Image Height : 2336
[IFD0] Bits Per Sample : 1
[IFD0] Compression : T6/Group 4 Fax
[IFD0] Photometric Interpretation : WhiteIsZero
[IFD0] Document Name : DN0P46383191 0000000023000000090000000.----!--11,0
[IFD0] Image Description :
[IFD0] Make : Eastman Kodak
[IFD0] Camera Model Name : Kodak Scanner: i4600
[IFD0] Strip Offsets : 8
[IFD0] Orientation : Horizontal (normal)
[IFD0] Samples Per Pixel : 1
[IFD0] Rows Per Strip : 2336
[IFD0] Strip Byte Counts : 24003
[IFD0] X Resolution : 200
[IFD0] Y Resolution : 200
[IFD0] Planar Configuration : Chunky
[IFD0] Resolution Unit : inches
[IFD0] Software : KODAK Capture Pro 3.1
[IFD0] Modify Date : 2012.12.07 14:10:23
[IFD0] Artist : aaa
<<<< CUT >>>>
[IFD591] Software : KODAK Capture Pro 3.1
[IFD591] Modify Date : 2012.12.07 14:16:55
[IFD591] Artist : aaa
[IFD592] Subfile Type : Full-resolution image
[IFD592] Image Width : 1678
[IFD592] Image Height : 2336
[IFD592] Bits Per Sample : 1
[IFD592] Compression : T6/Group 4 Fax
[IFD592] Photometric Interpretation : WhiteIsZero
[IFD592] Document Name : DN0P46383191 0000000056000000148900000.----!--11,0
[IFD592] Image Description :
[IFD592] Make : Eastman Kodak
[IFD592] Camera Model Name : Kodak Scanner: i4600
[IFD592] Strip Offsets : 18010488
[IFD592] Orientation : Horizontal (normal)
[IFD592] Samples Per Pixel : 1
[IFD592] Rows Per Strip : 2336
[IFD592] Strip Byte Counts : 13590
[IFD592] X Resolution : 200
[IFD592] Y Resolution : 200
[IFD592] Planar Configuration : Chunky
[IFD592] Resolution Unit : inches
[IFD592] Software : KODAK Capture Pro 3.1
[IFD592] Modify Date : 2012.12.07 14:16:56
[IFD592] Artist : aaaa
I don't understand the TIFF specification. The SubfileType for both images in your sample is 0 (Full-resolution image). If it is a multi-page tiff, shouldn't this be 2 (Single page of multi-page image)? You need to pay attention to SubfileType when counting pages because a standard TIFF with a thumbnail has 2 IFD's but you definitely wouldn't call this 2 pages. Also, depth maps and transparency masks shouldn't be counted as separate pages. Perhaps just IFD's with SubfileType 0 and 2 should be counted? What about sub-IFD's?
- Phil
I don't know the answers. Don't know TIFF at all.
I just thought that I am doing something wrong and that image count is hidden somewhere in exif.
I have send you a message with a link to mentioned file if you need it.
It is not a public file so cannot post link here.
I will add a feature to ExifTool to count the number of pages in a multi page TIFF, and return this in a PageCount tag.
- Phil
That would be awesome. PageCount like for PDFs.
Also, for TIFFs with many pages it is useful to know if TIFF is indeed multipage (has 2 or more pages) or not.
- See this https://github.com/image-js/tiff#tiffismultipagedata
Can this also be exposed as tag?
Won't the PageCount give you this? I won't generate the PageCount tag for a TIFF unless there is more than 1 page.
- Phil
Hm... it seems strange to me.
I would expect
- PageCount=1 when tiff is valid and parsed OK and has only one page
- PageCount=0 when something is wrong (detection failed) - combined with status code !=0
- PageCount>1 when there is a valid multi-page tiff
- there could be an optimization to stop parsing when detecting >1 pages - tag HasMultiPage=1 could be populated
When I get nothing I cannot parse it.
I don't know. Just thinking out loud here. You are the expert and know best how it will come together with other flags. :)
99.99% of all TIFF's in the wild would have PageCount = 1, so I don't think that is useful information and I would rather not make a change like this for current users who are perfectly happy the way things are. Also, there are so many TIFF-based formats, and basically all of them are single page, and a change to the TIFF reader would affect these as well unless I put in some extra logic to restrict this to only specific types of TIFF's.
- Phil
That makes sense.
Thank you for explaining the bigger picture.
Quote from: Phil Harvey on January 26, 2022, 07:30:46 AMI will add a feature to ExifTool to count the number of pages in a multi page TIFF, and return this in a PageCount tag.
- Phil
Hi, I try to know tiff page count but fail. It's implemented?
Yes. It will only return a PageCount if there is more than one page or if the multi-page document flag is set.
Be sure you are using an up-to-date version of ExifTool.
- Phil