TIFF error - Bad code word and setting wrong exit code

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
tiuser123
Posts: 6
Joined: 2013-05-14T03:51:29-07:00
Authentication code: 6789

TIFF error - Bad code word and setting wrong exit code

Post by tiuser123 »

Hello,

I have several TIFFs that we need to convert to PNG and I'm using imagemagick as a commandline tool in the backend.

The problem is that ImageMagick is experiencing an error during conversion with some of the tiffs (http://www.2shared.com/complete/vnb96t_9/error.html).
convert.exe: Unknown field with tag 292 (0x124) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Bad code word at line 5151 of strip 0 (x 3744). `Fax4Decode' @ error/tiff.c/TIFFErrors/562.

However, the TIFF can be viewed properly in the IMDisplay and other TIFF viewers and identify.exe doesn't encounter the error.
The PNG image is actually generated even though the above error is encountered however my program checks the error status which will be set to non-zero and the program will mark the conversion as failed.

From my initial investigation, this seems an error related to the compression used in TIFF (and I'm thinking that the underlying libtiff is throwing this). I'm not sure if this bug is related (http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=630042) Though I can't find a post with the exact error as mine.

Can someone advise the cause and if the error can be ignored and if imagemagick can handle or ignore the error?

I can ignore the above error via handling in my program and be satisfied with the PNG but I'm reluctant as I do not really know the exact cause of this error and it seems like the error message used is a general one (can i use "Fax4Decode' @ error/tiff.c/TIFFErrors/562" as the specific error indicator so I can ignore it?).

Tested with: Windows XP SP2, ImageMagick-6.8.5-6 (portable version)

Thanks
Last edited by tiuser123 on 2013-05-20T21:34:07-07:00, edited 1 time in total.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: TIFF conversion error - Bad code word

Post by magick »

The exception is thrown by the TIFF delegate library. Any hope of a resolution will need to come from the TIFF developers. ImageMagick simply calls the TIFF API and handles whatever pixels or exception it provides.
tiuser123
Posts: 6
Joined: 2013-05-14T03:51:29-07:00
Authentication code: 6789

Re: TIFF conversion error - Bad code word

Post by tiuser123 »

Oh, noted. Just hoping the someone here has some knowledge on TIFFs. Will post my question on their mailing list instead. Thanks.
tiuser123
Posts: 6
Joined: 2013-05-14T03:51:29-07:00
Authentication code: 6789

Re: TIFF conversion error - Bad code word

Post by tiuser123 »

On another note, can you advise why does imagemagick set the return code/exit status to 0 when i convert this tiff (http://www.2shared.com/photo/qRFYZMmS/e ... ccess.html) to PNG? (Note that a bad code word error is also shown among the multiple errors and warnings) While IM sets the status to non-zero in the TIF file in the first post?
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: TIFF conversion error - Bad code word

Post by magick »

Errors generate non-zero status. Warnings return a zero status.
tiuser123
Posts: 6
Joined: 2013-05-14T03:51:29-07:00
Authentication code: 6789

Re: TIFF conversion error - Bad code word

Post by tiuser123 »

Yes. but as stated there are several TIFFErrors (bad code word type of errors) amid the warnings. and I get 0 as the status code (note that I'm using java and calling IM as a commandline tool)

Does the exit status follow the last set (e.g since a warning was last seen then the status is reset to 0)?

convert.exe: Unknown field with tag 292 (0x124) encountered. `TIFFReadDirectory' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 815 of strip 0 (got 4673, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Bad code word at line 816 of strip 0 (x 743). `Fax4Decode' @ error/tiff.c/TIFFErrors/562.
convert.exe: Premature EOL at line 816 of strip 0 (got 743, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 819 of strip 0 (got 4673, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Bad code word at line 823 of strip 0 (x 741). `Fax4Decode' @ error/tiff.c/TIFFErrors/562.
convert.exe: Premature EOL at line 823 of strip 0 (got 741, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 825 of strip 0 (got 4674, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 826 of strip 0 (got 8603, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 830 of strip 0 (got 4673, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 833 of strip 0 (got 4673, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 837 of strip 0 (got 4673, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 845 of strip 0 (got 4675, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 851 of strip 0 (got 4673, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Uncompressed data (not supported) at line 854 of strip 0 (x 27). `Fax4Decode' @ error/tiff.c/TIFFErrors/562.
convert.exe: Premature EOL at line 854 of strip 0 (got 27, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 860 of strip 0 (got 4673, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 862 of strip 0 (got 8604, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Bad code word at line 863 of strip 0 (x 19). `Fax4Decode' @ error/tiff.c/TIFFErrors/562.
convert.exe: Premature EOL at line 863 of strip 0 (got 19, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 866 of strip 0 (got 4674, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Bad code word at line 872 of strip 0 (x 137). `Fax4Decode' @ error/tiff.c/TIFFErrors/562.
convert.exe: Premature EOL at line 872 of strip 0 (got 137, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Bad code word at line 876 of strip 0 (x 4671). `Fax4Decode' @ error/tiff.c/TIFFErrors/562.
convert.exe: Premature EOL at line 876 of strip 0 (got 4671, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Bad code word at line 878 of strip 0 (x 4671). `Fax4Decode' @ error/tiff.c/TIFFErrors/562.
convert.exe: Premature EOL at line 878 of strip 0 (got 4671, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Bad code word at line 879 of strip 0 (x 4671). `Fax4Decode' @ error/tiff.c/TIFFErrors/562.
convert.exe: Premature EOL at line 879 of strip 0 (got 4671, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 884 of strip 0 (got 4708, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 885 of strip 0 (got 4673, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 888 of strip 0 (got 4717, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 889 of strip 0 (got 4673, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 902 of strip 0 (got 4700, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 903 of strip 0 (got 4674, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Bad code word at line 907 of strip 0 (x 4670). `Fax4Decode' @ error/tiff.c/TIFFErrors/562.
convert.exe: Premature EOL at line 907 of strip 0 (got 4670, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 912 of strip 0 (got 4673, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 923 of strip 0 (got 4676, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 924 of strip 0 (got 4673, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 925 of strip 0 (got 4673, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 926 of strip 0 (got 4675, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Bad code word at line 929 of strip 0 (x 39). `Fax4Decode' @ error/tiff.c/TIFFErrors/562.
convert.exe: Premature EOL at line 929 of strip 0 (got 39, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 932 of strip 0 (got 4673, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 939 of strip 0 (got 4675, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Bad code word at line 943 of strip 0 (x 4671). `Fax4Decode' @ error/tiff.c/TIFFErrors/562.
convert.exe: Premature EOL at line 943 of strip 0 (got 4671, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 953 of strip 0 (got 4680, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Bad code word at line 957 of strip 0 (x 4671). `Fax4Decode' @ error/tiff.c/TIFFErrors/562.
convert.exe: Premature EOL at line 957 of strip 0 (got 4671, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 959 of strip 0 (got 4678, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Bad code word at line 966 of strip 0 (x 4). `Fax4Decode' @ error/tiff.c/TIFFErrors/562.
convert.exe: Premature EOL at line 966 of strip 0 (got 4, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 973 of strip 0 (got 4673, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 975 of strip 0 (got 4673, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Bad code word at line 980 of strip 0 (x 4671). `Fax4Decode' @ error/tiff.c/TIFFErrors/562.
convert.exe: Premature EOL at line 980 of strip 0 (got 4671, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 983 of strip 0 (got 4675, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Bad code word at line 987 of strip 0 (x 4671). `Fax4Decode' @ error/tiff.c/TIFFErrors/562.
convert.exe: Premature EOL at line 987 of strip 0 (got 4671, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 988 of strip 0 (got 4673, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 989 of strip 0 (got 4679, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
convert.exe: Line length mismatch at line 990 of strip 0 (got 4673, expected 4672). `Fax4Decode' @ warning/tiff.c/TIFFWarnings/824.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: TIFF conversion error - Bad code word

Post by magick »

Which version of ImageMagick are you using? We're using ImageMagick 6.8.5-6 and it returns 0 / 1 as expected. 0 for TIFF warnings and 1 for TIFF errors.
tiuser123
Posts: 6
Joined: 2013-05-14T03:51:29-07:00
Authentication code: 6789

Re: TIFF conversion error - Bad code word

Post by tiuser123 »

Using ImageMagick-6.8.5-6-Q16-x86-windows.zip (portable version), Windows XP SP2

also tried echo %errorlevel% and it returns 1 for the first TIFF and 0 for the second TIFF (even if the 2nd TIFF has errors).

Command I'm using is "<imagemagickpath>/convert.exe" errbutsuccess.tif sample.png

Even if I put -quiet, the error status is still 0 for the second TIFF.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: TIFF conversion error - Bad code word

Post by magick »

ImageMagick is returning the last exception rather than the exception of greatest severity. We'll add a patch to ImageMagick 6.8.5-7 Beta by sometime tomorrow. Thanks.
tiuser123
Posts: 6
Joined: 2013-05-14T03:51:29-07:00
Authentication code: 6789

Re: TIFF conversion error - Bad code word

Post by tiuser123 »

Ok. Thanks
alokob
Posts: 3
Joined: 2013-07-31T04:47:55-07:00
Authentication code: 6789

Re: TIFF error - Bad code word and setting wrong exit code

Post by alokob »

Exactly same issue is observed by me also in the same scenario , please can you let me know the reason and whether its fixed, and which version.

Thanks

Alok Bhandari.
Post Reply