Page 1 of 1
pdf(number of pages)
Posted: 2008-04-10T03:09:51-07:00
by webmagick
I have compiled IM6.4.0 with libtiff 3.82, ghostscript 8.62 gpl and libpng 1.2.25 on my Intel MacBook
Imagemagick runs some kind of infinite loop getting the number of pages in a pdf:
identify -format "%p" some.pdf
it also hangs if you try to extract all pages
Converting page 0 works though
Re: pdf(number of pages)
Posted: 2008-04-10T07:05:13-07:00
by magick
Does this work on all PDF's? If its just some, post a URL to your PDF so we can download and reproduce the problem. We're using ImageMagick 6.4.0-4 and your identify command properly reports the number of pages without complaint for all the PDF's we tested.
Re: pdf(number of pages)
Posted: 2008-04-10T08:06:40-07:00
by webmagick
It seems to be only one PDF (coincidentally the one I used for testing) failing completely to end (it has 411 pages).
--EDIT: it took 5 minutes to count the pages - so it seems I am just too impatient.--
It tried another one(
http://server.imento.dk/Imento%20samlet.pdf) and got an error:
Code: Select all
identify -format "%p" Imento\ samlet.pdf
**** Warning: CS/cs (setcolorspace) operand not a name: [/ICCBased {105 0 resolveR}] ****
**** This file had errors that were repaired or ignored.
**** The file was produced by:
**** >>>> Adobe PDF Library 8.0 <<<<
**** Please notify the author of the software that produced this
**** file that it does not conform to Adobe's published PDF
**** specification.
123456789101112
And another one
Code: Select all
identify -format "%p" ijs_spec.pdf
**** Error reading a content stream. The page may be incomplete.
**** File did not complete the page properly and may be damaged.
**** Error reading a content stream. The page may be incomplete.
**** Unknown operator: '1678..9'
Error: /typecheck in --.execform1--
Operand stack:
--nostringval-- --dict:7/16(L)-- 2
Execution stack:
%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-- 4 1 12 --nostringval-- %for_pos_int_continue --nostringval-- --nostringval-- --nostringval-- --nostringval-- %array_continue --nostringval-- false 1 %stopped_push --nostringval-- %loop_continue --nostringval-- 8249 --nostringval-- 1853 4 13 %oparray_pop --nostringval-- false 1 %stopped_push 1852 4 13 %oparray_pop --nostringval-- (gstatetype) --dict:0/0(L)-- --nostringval-- false 1 %stopped_push --nostringval-- %loop_continue
Dictionary stack:
--dict:1153/1684(ro)(G)-- --dict:1/20(G)-- --dict:75/200(L)-- --dict:75/200(L)-- --dict:108/127(ro)(G)-- --dict:275/300(ro)(G)-- --dict:22/25(L)-- --dict:4/6(L)-- --dict:24/40(L)-- --dict:1/1(ro)(G)-- --dict:1/1(ro)(G)-- --dict:1/1(ro)(G)-- --dict:1/1(ro)(G)-- --dict:5/5(L)-- --dict:1/1(ro)(G)--
Current allocation mode is local
Last OS error: 2
GPL Ghostscript 8.62: Unrecoverable error, exit code 1
identify: Postscript delegate failed `ijs_spec.pdf': No such file or directory.
How do I get the actual number of pages instead of all page numbers listed with no separation?
Re: pdf(number of pages)
Posted: 2008-04-10T09:18:34-07:00
by magick
If all you want is the number of pages in a PDF use another tool. ImageMagick must rasterize the PDF before it counts the number of pages. However, you can speed up the process with ImageMagick with this command:
- identify -density 12 -format "%p" image.pdf
The exception you received are from the Ghostscript delegate library. Either your PDF images are corrupt or its a bug in Ghostscript and you will want to post a bug report to them.