Page 1 of 1

libmagick++ throws exception on libtiff warning

Posted: 2014-07-28T09:24:43-07:00
by HeXetic
This may be related to the bug discussed in thread 23415:
viewtopic.php?t=23415

Code: Select all

try
{
std::vector<Magick::Image> pages;
Magick::readImages (&pages, "/var/tmp/generates-warning-fax.tiff");
}
catch (std::exception& e)
{
  std::cout << e.what();
}
With certain semi-broken TIFF files, Magick::readImages will throw an exception due to libTIFF generating a warning about an invalid line:

Code: Select all

Magick: /var/tmp/generates-warning-fax.tiff: Line length mismatch at line 2245 of strip 0 (got 1740, expected 1728). `Fax3Decode1D' @ warning/tiff.c/TIFFWarnings/857,2
However, the TIFF file is readable and can be converted (to PDF, for example) using the command-line "convert" utility:

Code: Select all

$ convert generates-warning-fax.tiff generates-warning-fax.pdf
convert.im6: generates-warning-fax.tiff: Line length mismatch at line 2245 of strip 0 (got 1740, expected 1728). `Fax3Decode1D' @ warning/tiff.c/TIFFWarnings/768.
$ ls -l generates-warning-fax.*
-rw-r--r-- 1 hexetic users 738790 Jul 28 12:18 generates-warning-fax.pdf
-rw------- 1 hexetic users 711572 Jul 28 10:37 generates-warning-fax.tiff
I suspect that what is happening is that Magick++ is throwing an exception, even though this is just a warning which does not prevent successful operation. Or am I missing some parameter to tell ImageMagick to ignore such warnings?

Re: libmagick++ throws exception on libtiff warning

Posted: 2014-07-28T09:35:20-07:00
by HeXetic
I forgot to mention, I tested this with a fresh download & compile of ImageMagick-6.8.9-6, but I was originally experiencing it in the Debian Stable version of 6.7.7.10-5+deb7u3

Re: libmagick++ throws exception on libtiff warning

Posted: 2014-07-28T11:48:07-07:00
by dlemstra
This is by design. Magick++ will throw exceptions that derive from Warning for warnings. You can catch and ignore them, the output image is still created.

Re: libmagick++ throws exception on libtiff warning

Posted: 2014-07-28T12:21:55-07:00
by HeXetic
Thanks for that help. I see the relevant section in the documentation now.