Page 1 of 1

Imagemagick PDF to JPG conversion failing

Posted: 2010-03-30T12:05:27-07:00
by sbressler
I'm trying to convert the first page of a PDF to a JPG. I'm pretty sure I got this to work with certain PDFs, but is it really possible that certain PDFs are made incorrectly and cannot be converted?

I tried running this first:

Code: Select all

$ convert 10-03-26.pdf[1] test.jpg
And I got the following:

Code: Select all

Error: /syntaxerror in readxref
Operand stack:
    
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1   3   %oparray_pop   1   3   %oparray_pop   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--
Dictionary stack:
   --dict:1062/1417(ro)(G)--   --dict:0/20(G)--   --dict:73/200(L)--   --dict:73/200(L)--   --dict:97/127(ro)(G)--   --dict:229/230(ro)(G)--   --dict:14/15(L)--
Current allocation mode is local
ESP Ghostscript 7.07.1: Unrecoverable error, exit code 1
convert: Postscript delegate failed `10-03-26.pdf'.
Running this instead:

Code: Select all

$ convert -verbose -colorspace rgb '10-03-26.pdf[1]' test.jpg
I get the following:

Code: Select all

Error: /syntaxerror in readxref
Operand stack:
    
Execution stack:
   %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1   3   %oparray_pop   1   3   %oparray_pop   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--   --nostringval--
Dictionary stack:
   --dict:1062/1417(ro)(G)--   --dict:0/20(G)--   --dict:73/200(L)--   --dict:73/200(L)--   --dict:97/127(ro)(G)--   --dict:229/230(ro)(G)--   --dict:14/15(L)--
Current allocation mode is local
ESP Ghostscript 7.07.1: Unrecoverable error, exit code 1
"gs" -q -dBATCH -dSAFER -dMaxBitmap=500000000 -dNOPAUSE -dAlignToPixels=0 "-sDEVICE=pnmraw" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-g792x1611" "-r72x72" -dFirstPage=2 -dLastPage=2 "-sOutputFile=/tmp/magick-XXU3T44P" "-f/tmp/magick-XXoMKL8Z" "-f/tmp/magic2eec1F"Start of Image
Define Huffman Table 0x00
          0   1   5   1   1   1   1   1
          1   0   0   0   0   0   0   0
Define Huffman Table 0x01
          0   3   1   1   1   1   1   1
          1   1   1   0   0   0   0   0
Define Huffman Table 0x10
          0   2   1   3   3   2   4   3
          5   5   4   4   0   0   1 125
Define Huffman Table 0x11
          0   2   1   2   4   4   3   4
          7   5   4   4   0   1   2 119
End Of Image
convert: Postscript delegate failed `10-03-26.pdf'.
Why would the conversion fail?

Thanks!

P.S. Just as an aside, this is happening on a (gs) Grid-Service on (mt) Media Temple hosting. I cannot install programs on the server, but both Imagemagick and Ghostscript are installed.

Re: Imagemagick PDF to JPG conversion failing

Posted: 2010-03-30T12:08:33-07:00
by magick
The exception is coming from Ghostscript. Do you have a modern version of Ghostscript? Perhaps 8.71 or above? If so, post a URL to your image so we can download and inspect it.

Re: Imagemagick PDF to JPG conversion failing

Posted: 2010-03-30T12:47:15-07:00
by sbressler
They seem to have version 7.07 installed (seemingly from 2003). Unfortunately, I have to work with what I have already installed on the server since it's part of a grid. Also, I'm converting from PDF to JPG, not the other way around. Sample PDFs galore: http://www.studlife.com/pdf-archive/.

Re: Imagemagick PDF to JPG conversion failing

Posted: 2010-03-30T14:14:46-07:00
by magick
You need a more recent version of Ghostscript. Without the upgrade, you can expect the occasional PDF to fail. There has been a lot of improvements and bug fixes to Ghostscript to better support PDF since the 7.07 release.

Re: Imagemagick PDF to JPG conversion failing

Posted: 2010-03-30T14:18:22-07:00
by sbressler
I can't expect (mt) Media Temple to upgrade anytime soon, so in the meantime, is there anything I can do during PDF generation to make Ghostscript less likely to fail? I'm creating these PDFs by combining many PDFs in Adobe Acrobat, each of which are generated from Adobe Distiller. I have full control over the settings under which these PDFs and eventually the combined PDF are created.

Re: Imagemagick PDF to JPG conversion failing

Posted: 2010-03-30T14:26:54-07:00
by magick
We recommend you post your questions to the Ghostscript users mailing list.

Re: Imagemagick PDF to JPG conversion failing

Posted: 2010-03-30T14:47:20-07:00
by sbressler
Okay, thanks for the help. Just to confirm, is this the list? http://ghostscript.com/cgi-bin/mailman/ ... o/gs-devel