Page 1 of 1

Invalid TIFF directory; tags are not sorted in ascending order. `TIFFReadDirectoryCheckOrder'

Posted: 2018-04-16T04:47:00-07:00
by punith8626
Hello,

I am trying to convert tiff file and i get below error message when i try to convert tiff to png.

Code: Select all

convert.exe: Invalid TIFF directory; tags are not sorted in ascending order. `TIFFReadDirectoryCheckOrder' @ warning/tiff.c/TIFFWarnings/768.
convert.exe: ASCII value for tag "Artist" contains null byte in value; value incorrectly truncated during reading due to implementation limitations. `TIFFFetchNormalTag' @ warning/tiff.c/TIFFWarnings/768.
convert.exe: Depreciated and troublesome old-style JPEG compression mode, please convert to new-style JPEG compression and notify vendor of writing software. `OJPEGSetupDecode' @ warning/tiff.c/TIFFWarnings/768.
convert.exe: Missing JPEG tables. `OJPEGReadHeaderInfoSecTablesQTable' @ error/tiff.c/TIFFErrors/508.
Is there any solution for this?
I am using ImageMagick-6.7.7-Q16 with windoes 7 environment.

Re: Invalid TIFF directory; tags are not sorted in ascending order. `TIFFReadDirectoryCheckOrder'

Posted: 2018-04-16T05:35:03-07:00
by Bonzo
Is the final image created? If so you may be able to ignore the errors.
What happens if you try a file from another source - if this works it could be the problem with the software that creates the tiff. Use different software to create it
What is your actual code?
Have you tried in a different Imagemagick version?
You need to upload the problem file somewhere so the members here can try it.

Re: Invalid TIFF directory; tags are not sorted in ascending order. `TIFFReadDirectoryCheckOrder'

Posted: 2018-04-16T10:16:42-07:00
by fmw42
The first 3 are just warnings and can be ignore. The last implies there is a malformed TIFF which is missing the JPEG tables, assuming it is JPEG compressed.

Re: Invalid TIFF directory; tags are not sorted in ascending order. `TIFFReadDirectoryCheckOrder'

Posted: 2018-04-17T07:31:14-07:00
by punith8626
Bonzo wrote: 2018-04-16T05:35:03-07:00 Is the final image created? If so you may be able to ignore the errors.
What happens if you try a file from another source - if this works it could be the problem with the software that creates the tiff. Use different software to create it
What is your actual code?
Have you tried in a different Imagemagick version?
You need to upload the problem file somewhere so the members here can try it.
- convert C:\Users\Desktop\lense\NotWorking.tif C:\Users\Desktop\lense\NotWorking.png
- I tried with image magic versions like ImageMagick-7 and ImageMagick-6.7.7-Q16 so far not output. We get output as black screen
- I have restriction to upload the corrupted file to forum
- I tried the convert same image using laserfiche and coolutils and I am able to convert it.

Re: Invalid TIFF directory; tags are not sorted in ascending order. `TIFFReadDirectoryCheckOrder'

Posted: 2018-04-17T09:37:47-07:00
by fmw42
Tiff is a very customizable format. I suspect those tools are not sensitive to proper tiff formatting. Libtiff may be more sensitive to such changes. So I still think this is a malformed or very customized image TIFF formatting that libtiff will not handle.

Can you generate a TIFF image that is not proprietary and provide a link to it here?

Re: Invalid TIFF directory; tags are not sorted in ascending order. `TIFFReadDirectoryCheckOrder'

Posted: 2018-04-19T07:35:24-07:00
by punith8626
I tried with coolutils and i am able to convert it but not with image magic
https://www.coolutils.com/CommandLine/T ... eConverter

Re: Invalid TIFF directory; tags are not sorted in ascending order. `TIFFReadDirectoryCheckOrder'

Posted: 2018-04-22T21:59:50-07:00
by punith8626
Any update on this?

Re: Invalid TIFF directory; tags are not sorted in ascending order. `TIFFReadDirectoryCheckOrder'

Posted: 2018-04-23T02:46:34-07:00
by snibgo
tiffcp and Windows Photo Viewer can't open it.

Gimp doesn't complain, and makes an image that seems entirely black.

IM complains, but makes an image that is entirely black.

A developer may take a look, but I doubt that IM will be modified to read this file.

Re: Invalid TIFF directory; tags are not sorted in ascending order. `TIFFReadDirectoryCheckOrder'

Posted: 2018-04-23T06:31:08-07:00
by punith8626
punith8626 wrote: 2018-04-19T07:35:24-07:00 I tried with coolutils and i am able to convert it but not with image magic
https://www.coolutils.com/CommandLine/T ... eConverter

Re: Invalid TIFF directory; tags are not sorted in ascending order. `TIFFReadDirectoryCheckOrder'

Posted: 2018-04-23T07:34:43-07:00
by 246246
According to tiffdump,

Code: Select all

$ tiffdump NotWorking.tiff 
NotWorking.tiff:
Magic: 0x4949 <little-endian> Version: 0x2a <ClassicTIFF>
Directory 0: offset 8 (0x8) next 0 (0)
SubFileType (254) LONG (4) 1<0>
ImageWidth (256) LONG (4) 1<1700>
ImageLength (257) LONG (4) 1<2200>
BitsPerSample (258) SHORT (3) 1<8>
Compression (259) SHORT (3) 1<6>
Photometric (262) SHORT (3) 1<3>
FillOrder (266) SHORT (3) 1<1>
StripOffsets (273) LONG (4) 1<2046>
Orientation (274) SHORT (3) 1<1>
SamplesPerPixel (277) SHORT (3) 1<1>
RowsPerStrip (278) LONG (4) 1<2200>
StripByteCounts (279) LONG (4) 1<477825>
XResolution (282) RATIONAL (5) 1<200>
YResolution (283) RATIONAL (5) 1<200>
PlanarConfig (284) SHORT (3) 1<1>
ResolutionUnit (296) SHORT (3) 1<2>
DateTime (306) ASCII (2) 20<2018:02:23 11:45:16\0>
Artist (315) ASCII (2) 200<2004 SNOWBOUND, ALL RIGH ...>
JPEGInterchangeFormat (513) LONG (4) 1<516>
Colormap (320) SHORT (3) 768<0 65280 768 0 0 768 0 0 1024 0 4608 768 0 0 768 0 0 1024 0 0 1024 0 256 1280 ...>
your data is located at 2046 byte point and its byte count is 477825. As everyone says, this is likely to be a non-standard tiff file, however, when compression is old-jpeg, raw data is sometimes found there.

Code: Select all

$ tail -c+2047 NotWorking.tiff | od -cx | head
0000000  377 330 377 340  \0 020   J   F   I   F  \0 001  \0 001  \0 000
             d8ff    e0ff    1000    464a    4649    0100    0100    c800
0000020   \0 310  \0  \0 377 333  \0 204  \0 020  \v  \f 016  \f  \n 020
             c800    0000    dbff    8400    1000    0c0b    0c0e    100a
0000040  016  \r 016 022 021 020 023 030   ( 032 030 026 026 030   1   #
             0d0e    120e    1011    1813    1a28    1618    1816    2331
0000060    % 035   (   :   3   =   <   9   3   8   7   @   H   \   N   @
             1d25    3a28    3d33    393c    3833    4037    5c48    404e
0000100    D   W   E   7   8   P   m   Q   W   _   b   g   h   g   >   M
             5744    3745    5038    516d    5f57    6762    6768    4d3e
Well, it looks JFIF format, so you can extract the data cutting the header (and the trailer if it has).

Code: Select all

$ tail -c+2047 NotWorking.tiff | head -c 477825 > tmp.jpg
$ identify tmp.jpg 
tmp.jpg JPEG 1700x2200 1700x2200+0+0 8-bit Gray 256c 477825B 0.000u 0:00.000
Now I can see the file with display command and can convert it to png.

Re: Invalid TIFF directory; tags are not sorted in ascending order. `TIFFReadDirectoryCheckOrder'

Posted: 2018-04-24T03:00:08-07:00
by punith8626
246246 wrote: 2018-04-23T07:34:43-07:00 According to tiffdump,

Code: Select all

$ tiffdump NotWorking.tiff 
NotWorking.tiff:
Magic: 0x4949 <little-endian> Version: 0x2a <ClassicTIFF>
Directory 0: offset 8 (0x8) next 0 (0)
SubFileType (254) LONG (4) 1<0>
ImageWidth (256) LONG (4) 1<1700>
ImageLength (257) LONG (4) 1<2200>
BitsPerSample (258) SHORT (3) 1<8>
Compression (259) SHORT (3) 1<6>
Photometric (262) SHORT (3) 1<3>
FillOrder (266) SHORT (3) 1<1>
StripOffsets (273) LONG (4) 1<2046>
Orientation (274) SHORT (3) 1<1>
SamplesPerPixel (277) SHORT (3) 1<1>
RowsPerStrip (278) LONG (4) 1<2200>
StripByteCounts (279) LONG (4) 1<477825>
XResolution (282) RATIONAL (5) 1<200>
YResolution (283) RATIONAL (5) 1<200>
PlanarConfig (284) SHORT (3) 1<1>
ResolutionUnit (296) SHORT (3) 1<2>
DateTime (306) ASCII (2) 20<2018:02:23 11:45:16\0>
Artist (315) ASCII (2) 200<2004 SNOWBOUND, ALL RIGH ...>
JPEGInterchangeFormat (513) LONG (4) 1<516>
Colormap (320) SHORT (3) 768<0 65280 768 0 0 768 0 0 1024 0 4608 768 0 0 768 0 0 1024 0 0 1024 0 256 1280 ...>
your data is located at 2046 byte point and its byte count is 477825. As everyone says, this is likely to be a non-standard tiff file, however, when compression is old-jpeg, raw data is sometimes found there.

Code: Select all

$ tail -c+2047 NotWorking.tiff | od -cx | head
0000000  377 330 377 340  \0 020   J   F   I   F  \0 001  \0 001  \0 000
             d8ff    e0ff    1000    464a    4649    0100    0100    c800
0000020   \0 310  \0  \0 377 333  \0 204  \0 020  \v  \f 016  \f  \n 020
             c800    0000    dbff    8400    1000    0c0b    0c0e    100a
0000040  016  \r 016 022 021 020 023 030   ( 032 030 026 026 030   1   #
             0d0e    120e    1011    1813    1a28    1618    1816    2331
0000060    % 035   (   :   3   =   <   9   3   8   7   @   H   \   N   @
             1d25    3a28    3d33    393c    3833    4037    5c48    404e
0000100    D   W   E   7   8   P   m   Q   W   _   b   g   h   g   >   M
             5744    3745    5038    516d    5f57    6762    6768    4d3e
Well, it looks JFIF format, so you can extract the data cutting the header (and the trailer if it has).

Code: Select all

$ tail -c+2047 NotWorking.tiff | head -c 477825 > tmp.jpg
$ identify tmp.jpg 
tmp.jpg JPEG 1700x2200 1700x2200+0+0 8-bit Gray 256c 477825B 0.000u 0:00.000
Now I can see the file with display command and can convert it to png.

Is 2046 and 477825 is common for all the files ? If not How do i get to know which bytes needs to remove.

Re: Invalid TIFF directory; tags are not sorted in ascending order. `TIFFReadDirectoryCheckOrder'

Posted: 2018-04-24T03:17:31-07:00
by 246246
punith8626 wrote: 2018-04-24T03:00:08-07:00 Is 2046 and 477825 is common for all the files ? If not How do i get to know which bytes needs to remove.
See

Code: Select all

StripOffsets (273) LONG (4) 1<2046>
StripByteCounts (279) LONG (4) 1<477825>
from command output above. If all your files are created by same software, there is a chance to be able to extract the file same way. tiffdump command comes from libtiff.

Re: Invalid TIFF directory; tags are not sorted in ascending order. `TIFFReadDirectoryCheckOrder'

Posted: 2018-10-21T22:16:57-07:00
by punith8626
Hello,

Sometimes when i run the tiffdump command I get permission denied.