2010.09.10 16:13 "[Tiff] most libtiff utilities failing with multi-image tiffs", by Duane Evenson

2010.09.10 16:13 "[Tiff] most libtiff utilities failing with multi-image tiffs", by Duane Evenson

I'm creating a bunch of multi-image tiffs from my scanner using HP Solution Center. tiffsplit and most other utilities fail with some tiffs. tiffdump is the only utility that works on all the files. The error I get is 'Error fetching data for field "BitsPerSample".'

Imagemagick's convert is able to split the files, although it is very slow. I'd like to use the more speedy libtiff utilities. Does anyone know what the problem is?

Here is the results of my tests looking for a common denominator. The
bad files are clumped together when sorted by file size. Between 2 GB
and 2.6-3.5 GB, the libtiff ulities fail. Still, there are three OK
files with even larger sizes than the bad ones, so size may not be the
problem.

Name      #imgs max(x)  max(y)  min(x)  min(y)  Size
0007.tif    1   81      527     81      527     324573
0022.tif    1   10055   15742   10055   15742   1244507260
0018.tif    2   9580    14882   6032    8576    1484328944
0021.tif    1   12009   17001   12009   17001   1509722138
0009.tif    2   9644    14324   9352    8413    1536057888
0017.tif    3   9553    14913   4319    4639    1635070887
0008.tif    2   9582    14485   8456    12120   1811613084
0025.tif    1   13269   20683   13269   20683   2078684139
0026.tif    1   13232   20816   13232   20816   2099106538
0027.tif    1   13246   20653   13246   20653   2104836840
0004.tif    4   8401    13050   4749    5924    2113028383
0028.tif    1   13327   20815   13327   20815   2138786713
0001.tif *  4   8287    12015   6088    8656    2272357106
0010.tif *  2   11964   16554   8524    12114   2299204501
0011.tif *  2   16800   11936   13956   8402    2416202296
0003.tif *  4   11325   12300   8453    6117    2420160907
0015.tif *  3   12132   15674   9205    6678    2460989159
0014.tif *  3   17050   11908   7783    6655    2485415143
0013.tif *  3   17067   11909   7868    6673    2496772884
0019.tif *  4   8575    14134   6081    5791    2512993200
0006.tif *  4   10932   15616   8575    6047    2528355266
0020.tif *  2   14589   16556   13021   9646    2656119233
0012.tif *  5   13368   13426   4048    5504    2727440368
0016.tif *  3   12170   17096   6126    8533    2756565054
0005.tif *  4   10289   15882   6177    8489    2861084579
0024.tif    2   16262   15229   16261   15198   3802821035
0002.tif    7   8765    12829   6063    8523    3987660409
0023.tif    2   13374   20645   13295   20639   4292704687

* - bad multi-image on which libtiff failed
x - imageWidth
y - imageLength

Here is a sample of the output from tiffdump for 0009.tif (good) and 0010.tif (bad). There doesn't seem to be anything markedly different between them.

0009.tif:
Magic: 0x4949 <little-endian> Version: 0x2a
Directory 0: offset 8 (0x8) next 1004988714 (0x3be6e92a)
SubFileType (254) LONG (4) 1<2>
ImageWidth (256) LONG (4) 1<9352>
ImageLength (257) LONG (4) 1<14324>
BitsPerSample (258) SHORT (3) 3<16 16 16>
Compression (259) SHORT (3) 1<5>
Photometric (262) SHORT (3) 1<2>
StripOffsets (273) LONG (4) 896<7396 1081313 2210272 3344850 4485895
5628829 6772132 7916776 9059902 10203611 11344724 12485398 13625967
14766849 15907048 17045962 18184471 19321509 20458111 21592773 22725453
23858544 24990167 26119783 ...>
Orientation (274) SHORT (3) 1<1>
SamplesPerPixel (277) SHORT (3) 1<3>
RowsPerStrip (278) LONG (4) 1<16>
StripByteCounts (279) LONG (4) 896<1073917 1128959 1134578 1141045
1142934 1143303 1144644 1143126 1143709 1141113 1140674 1140569 1140882
1140199 1138914 1138509 1137038 1136602 1134662 1132680 1133091 1131623
1129616 1127997 ...>
XResolution (282) RATIONAL (5) 1<2400>
YResolution (283) RATIONAL (5) 1<2400>
PlanarConfig (284) SHORT (3) 1<1>
ResolutionUnit (296) SHORT (3) 1<2>
PageNumber (297) SHORT (3) 2<0 0>

Directory 1: offset 1004988714 (0x3be6e92a) next 0 (0)
SubFileType (254) LONG (4) 1<2>
ImageWidth (256) LONG (4) 1<9644>
ImageLength (257) LONG (4) 1<8413>
BitsPerSample (258) SHORT (3) 3<16 16 16>
Compression (259) SHORT (3) 1<5>
Photometric (262) SHORT (3) 1<2>
StripOffsets (273) LONG (4) 526<1004993142 1006016812 1006607414
1007108116 1007553244 1007966413 1008368341 1008761168 1009154730
1009544996 1009940835 1010344595 1010753955 1011168026 1011589666
1012012430 1012441245 1012876388 1013315935 1013757431 1014199917
1014641755 1015083170 1015527458 ...>
Orientation (274) SHORT (3) 1<1>
SamplesPerPixel (277) SHORT (3) 1<3>
RowsPerStrip (278) LONG (4) 1<16>
StripByteCounts (279) LONG (4) 526<1023670 590602 500702 445128 413169
401928 392827 393562 390266 395839 403760 409360 414071 421640 422764
428815 435143 439547 441496 442486 441838 441415 444288 443441 ...>
XResolution (282) RATIONAL (5) 1<2400>
YResolution (283) RATIONAL (5) 1<2400>
PlanarConfig (284) SHORT (3) 1<1>
ResolutionUnit (296) SHORT (3) 1<2>
PageNumber (297) SHORT (3) 2<0 1>

0010.tif:
Magic: 0x4949 <little-endian> Version: 0x2a
Directory 0: offset 8 (0x8) next 1499350510 (0x595e45ee)
SubFileType (254) LONG (4) 1<2>
ImageWidth (256) LONG (4) 1<11964>
ImageLength (257) LONG (4) 1<16554>
BitsPerSample (258) SHORT (3) 3<16 16 16>
Compression (259) SHORT (3) 1<5>
Photometric (262) SHORT (3) 1<2>
StripOffsets (273) LONG (4) 1035<8508 1458995 2910406 4358106 5807181
7255640 8704673 10151221 11594653 13034491 14473741 15916967 17361093
18808745 20258131 21709422 23158820 24607083 26053132 27500529 28954762
30407970 31860921 33313317 ...>
Orientation (274) SHORT (3) 1<1>
SamplesPerPixel (277) SHORT (3) 1<3>
RowsPerStrip (278) LONG (4) 1<16>
StripByteCounts (279) LONG (4) 1035<1450487 1451411 1447700 1449075
1448459 1449033 1446548 1443432 1439838 1439250 1443226 1444126 1447652
1449386 1451291 1449398 1448263 1446049 1447397 1454233 1453208 1452951
1452396 1452686 ...>
XResolution (282) RATIONAL (5) 1<2400>
YResolution (283) RATIONAL (5) 1<2400>
PlanarConfig (284) SHORT (3) 1<1>
ResolutionUnit (296) SHORT (3) 1<2>
PageNumber (297) SHORT (3) 2<0 0>

Directory 1: offset 1499350510 (0x595e45ee) next 0 (0)
SubFileType (254) LONG (4) 1<2>
ImageWidth (256) LONG (4) 1<8524>
ImageLength (257) LONG (4) 1<12114>
BitsPerSample (258) SHORT (3) 3<16 16 16>
Compression (259) SHORT (3) 1<5>
Photometric (262) SHORT (3) 1<2>
StripOffsets (273) LONG (4) 758<1499356794 1500409267 1501443353
1502467881 1503488386 1504505440 1505519936 1506532056 1507542742
1508554232 1509565106 1510575885 1511586613 1512598455 1513609540
1514622034 1515635255 1516647599 1517660742 1518672165 1519684817
1520697377 1521710018 1522723671 ...>
Orientation (274) SHORT (3) 1<1>
SamplesPerPixel (277) SHORT (3) 1<3>
RowsPerStrip (278) LONG (4) 1<16>
StripByteCounts (279) LONG (4) 758<1052473 1034086 1024528 1020505
1017054 1014496 1012120 1010686 1011490 1010874 1010779 1010728 1011842
1011085 1012494 1013221 1012344 1013143 1011423 1012652 1012560 1012641
1013653 1013773 ...>
XResolution (282) RATIONAL (5) 1<2400>
YResolution (283) RATIONAL (5) 1<2400>
PlanarConfig (284) SHORT (3) 1<1>
ResolutionUnit (296) SHORT (3) 1<2>
PageNumber (297) SHORT (3) 2<0 1>