libmagick++ throws exception on libtiff warning

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
HeXetic
Posts: 3
Joined: 2014-07-28T09:13:40-07:00
Authentication code: 6789

libmagick++ throws exception on libtiff warning

Post 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?
HeXetic
Posts: 3
Joined: 2014-07-28T09:13:40-07:00
Authentication code: 6789

Re: libmagick++ throws exception on libtiff warning

Post 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
User avatar
dlemstra
Posts: 1570
Joined: 2013-05-04T15:28:54-07:00
Authentication code: 6789
Contact:

Re: libmagick++ throws exception on libtiff warning

Post 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.
.NET + ImageMagick = Magick.NET https://github.com/dlemstra/Magick.NET, @MagickNET, Donate
HeXetic
Posts: 3
Joined: 2014-07-28T09:13:40-07:00
Authentication code: 6789

Re: libmagick++ throws exception on libtiff warning

Post by HeXetic »

Thanks for that help. I see the relevant section in the documentation now.
Post Reply