Mark Fischer
Mark Fischer

Reputation: 1

pdf to jpg conversion

I normally create a jpg thumbnail from PDF files this way:

exec('convert -contrast ./xyz.pdf[0] ./xyz.jpg');

Alternativly I can also use this variation to create the thumbnails:

exec("/usr/bin/gs -q -dBATCH -dMaxBitmap=300000000 -dNOPAUSE -dSAFER -sDEVICE=jpeg -dJPEGQ=100 -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -r72 -dFirstPage=1 -dLastPage=1 -sOutputFile=./xyz.jpg ./xyz.pdf -c quit");

Now most of the thumbnails are created without any problems. But there are alwasy some cases where the thumbnails aren't created at all. No matter which of the two variations I use. The PDF files seem to be "ok" (at least I can open and view them without any problems).

Is there any other way to get the thumbnails (via script) that could work?

Thanks a lot

The error message I receive is:

[0] => Error: /limitcheck in --run--
[1] => Operand stack:
[2] =>    --nostringval--   --dict:9/18(L)--   --nostringval--
[3] => Execution stack:
[4] =>    %interp_exit   .runexec2   --nostringval--   --nostringval--   --nostringval--   2   %stopped_push   --nostringval--   --nostringval--   --nostringval--   false   1   %stopped_push   1905   1   3   %oparray_pop   1904   1   3   %oparray_pop   1888   1   3   %oparray_pop   --nostringval--   --nostringval--   2   1   1   --nostringval--   %for_pos_int_continue   --nostringval--   --nostringval--   --nostringval--   --nostringval--   %array_continue   --nostringval--   false   1   %stopped_push   --nostringval--   %loop_continue   --nostringval--
[5] => Dictionary stack:
[6] =>    --dict:1159/1684(ro)(G)--   --dict:2/20(G)--   --dict:97/200(L)--   --dict:97/200(L)--   --dict:107/127(ro)(G)--   --dict:275/300(ro)(G)--   --dict:22/25(L)--   --dict:4/6(L)--   --dict:22/40(L)--   --dict:1/1(ro)(G)--   --dict:1/1(ro)(G)--
[7] => Current allocation mode is local
[8] => Last OS error: 2

Upvotes: 0

Views: 1355

Answers (2)

mark stephens
mark stephens

Reputation: 3184

I posted a blog article on how to find out the PDF version used in a PDF file at http://www.jpedal.org/PDFblog/2010/09/how-do-i-find-out-the-pdf-version-used/

Upvotes: 1

pstrjds
pstrjds

Reputation: 17428

Add the -verbose flag. It will give you all sorts of extra information.
My suspicion would be the version of the PDF file that is causing your issue. ImageMagick uses Ghostscript to process PDFs. I am not sure what version of PDF Ghostscript currently supports, but most opensource tools do not handle the latest version of PDF files.

Edit: Thought I should add this note, not sure what scripting language you are using to exec from or what OS you are on, but you will probably need to parse the error stream to get the information from the commands. Not sure if the verbose output is written to the error stream, but I am fairly sure the error information (invalid file format, etc) is written to the error stream.

Upvotes: 1

Related Questions