convert fails with purportedly valid pdfs

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
tallenaz
Posts: 2
Joined: 2015-04-20T10:29:41-07:00
Authentication code: 6789

convert fails with purportedly valid pdfs

Post by tallenaz »

I have a batch of pdfs from a vendor, who says they are valid. I'm trying to convert them to pngs with the following command:

Code: Select all

convert -density 400 foo.pdf -resize 30% -quality 92 foo.png
With one pdf (60779014.pdf), convert hangs, and with the other (60779212.pdf), I get the following output:
jbig2dec FATAL ERROR decoding image: symbol id out of range! (195/156) (segment 0x03)

**** Warning: File has insufficient data for an image.
jbig2dec FATAL ERROR decoding image: runlength too large in export symbol table (272 > 169 - 0)
(segment 0x02)

**** Warning: File has insufficient data for an image.
jbig2dec FATAL ERROR decoding image: runlength too large in export symbol table (441 > 158 - 0)
(segment 0x02)

**** Warning: File has insufficient data for an image.

**** This file had errors that were repaired or ignored.
**** Please notify the author of the software that produced this
**** file that it does not conform to Adobe's published PDF
**** specification.
In this case, convert produces 3 pngs from the pdf, but 2 of the 3 are blank. What I want is 3 pngs, one for each page of the pdf, none blank.

I've tested this out with two versions of ImageMagick/Ghostscript -- 6.5.4-7/8.70 and 6.9.0-3/9.15, and get the same results.

I've also tried the command out on a randomly selected pdf from elsewhere, and convert does just fine.

I suspect there is something wrong with the pdfs, but since the vendor claims they're valid, I want to ask if anyone in the imagemagick community can spot an ImageMagick problem here.
I've included links to the offending pdfs, if you'd like to help.

https://www.dropbox.com/s/baobf9jf99tsa ... 4.pdf?dl=0
https://www.dropbox.com/s/duzncjwvo6nai ... 2.pdf?dl=0
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert fails with purportedly valid pdfs

Post by fmw42 »

This works for me on IM 6.9.1.1 Q16 Mac OSX and GS 9.10

Code: Select all

convert -density 400 -alpha off 60779014.pdf[0] -resize 30% test0.png
But any page after the first hangs for me. I do not get any error messages (you may need to update your jbig delegate library)

Code: Select all

convert -density 400 -alpha off 60779014.pdf[1] -resize 30% test1.png

I am not sure why it gets the first page, but none of the others.

Note that -quality 92 is not what you expect for PNG. See http://www.imagemagick.org/script/comma ... hp#quality

Even identify hangs on the full image

Code: Select all

identify 60779014.pdf
so something would appear not to be compatible in your pdf with with my GS 9.10. Perhaps I need to upgrade my GS.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert fails with purportedly valid pdfs

Post by snibgo »

Both PDFs convert with IM 6.9.1-0 and GS 9.15 on Windows 8.1, with no problem, for me.

pdfimages complains about "Syntax Warning: Invalid Font Weight".
snibgo's IM pages: im.snibgo.com
tallenaz
Posts: 2
Joined: 2015-04-20T10:29:41-07:00
Authentication code: 6789

Re: convert fails with purportedly valid pdfs

Post by tallenaz »

Thanks all, for the feedback. On Mac OSX, I upgraded ImageMagick to 6.9.1-2 and Ghostscript to 9.16, and the pdfs convert as expected. I appreciate the comment on the -quality flag as well.
pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: convert fails with purportedly valid pdfs

Post by pipitas »

tallenaz wrote:I suspect there is something wrong with the pdfs, but since the vendor claims they're valid, I want to ask if anyone in the imagemagick community can spot an ImageMagick problem here.
This looks like it is a PDF decoding problem in the first place.

PDF decoding is accomplished by Ghostscript (on ImageMagick's behalf) and transformed into raster data before it really reaches `convert`.

That means, the ImageMagick community is not likely to be the best place to put this problem before. You'd probably be better of to seek help from the Ghostscript folks. They are on Freenode-IRC in channel #ghostscript for example, and very friendly. They also have a well maintained Bugzilla bug tracker: http://bugs.ghostscript.com/

Having said that, I'll now download and have a look at the PDFs. (I'm on a veeery slow internet link right now, though...)
pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

Re: convert fails with purportedly valid pdfs

Post by pipitas »

tallenaz wrote:I upgraded ImageMagick to 6.9.1-2 and Ghostscript to 9.16, and the pdfs convert as expected. I appreciate the comment on the -quality flag as well.
Oh, well... I'll not download your PDFs then :-)
Post Reply