Page 1 of 2

Problems selecting frames

Posted: 2009-07-17T07:46:29-07:00
by seedy
I'm trying to convert a pdf to png's. It works fine when I want to do the entire pdf:

Code: Select all

convert.exe input.pdf output.png
I end up with a png file for each page (output-1.png, output-2.png) ect. However when I try to use a frame range, I only ever get one output file. And it's always the first page specified in the range.

Code: Select all

convert.exe input.pdf[2-5] output.png
In the case shown, I get only one output file (output.png), and it is the page 2 of the pdf. The same problem occurs if I use:

Code: Select all

convert.exe input.pdf[2,3,4,5] output.png
-verbose output is
[ghostscript library] Files/gs/gs8.64/bin/gswin32c.exe" -q -dQUIET -dPARANOIDSAF
ER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dEPSCrop -dAlignToPixels=0 -dGridFitTT=0 "-sDEVICE=bmpsep8" -dTextAlphaBits=4 -dGraphicsAlphaBits=4 "-r72x72" -dUseCIEColor -dFirstPage=3 -dLastPage=6 "-sOutputFile=C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/magick-twIFSS-G" "-fC:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/magick-6566-Ir_" "-f
C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/magick-WZV_H5ej"C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/magick-twIFSS-G[0] BMP 611x395 611x395+0+0 8-bit PseudoClass 256c 3.706mb
C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/magick-twIFSS-G[1] BMP 611x395 611x395+0+0 8-bit PseudoClass 256c 3.706mb
C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/magick-twIFSS-G[2] BMP 611x395 611x395+0+0 8-bit PseudoClass 256c 3.706mb
C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/magick-twIFSS-G[3] BMP 611x395 611x395+0+0 8-bit PseudoClass 256c 3.706mb
C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/magick-twIFSS-G[4] BMP 611x395 611x395+0+0 8-bit PseudoClass 256c 3.706mb
C:/DOCUME~1/ADMINI~1/LOCALS~1/Temp/magick-twIFSS-G[5] BMP 611x395 611x395+0+0 8-bit PseudoClass 256c 3.706mb
cat_Scott_2006.pdf[2-5]=>cat_Scott_2006.pdf PDF 611x395 611x395+0+0 16-bit DirectClass
cat_Scott_2006.pdf[2-5]=>Output.png PDF 611x395 611x395+0+0 16-bit DirectClass 624kb 0.344u 0:01
Am I doing something wrong or is this a bug ?

Re: Problems selecting frames

Posted: 2009-07-24T05:49:21-07:00
by seedy
Any Insight on this? Is there more info anyone would like to know ?

Re: Problems selecting frames

Posted: 2009-07-24T09:59:55-07:00
by fmw42
PNG does not support multiple frames! So you need to use GIF, TIF or MIFF

convert rose: rose: rose: rose: rose: rose.pdf
convert rose.pdf[2-4] rose.png
identify rose.png
rose.png PNG 70x46 70x46+0+0 8-bit DirectClass 6.78kb

So you need to make it generate multiple images
convert rose.pdf[2-4] rose_%d.png
returns rose_0.png rose_1.png rose_2.png

Or
convert rose.pdf[2-4] +adjoin rose.png
returns rose-0.png rose-1.png rose-2.png

But
convert rose.pdf[2-4] rose.gif
identify rose.gif
rose.gif[0] GIF 70x46 70x46+0+0 8-bit PseudoClass 256c 10.6kb
rose.gif[1] GIF 70x46 70x46+0+0 8-bit PseudoClass 256c 10.6kb
rose.gif[2] GIF 70x46 70x46+0+0 8-bit PseudoClass 256c 10.6kb

Re: Problems selecting frames

Posted: 2009-07-24T10:04:32-07:00
by magick
What version of ImageMagick are you using? We're using ImageMagick 6.5.4-5 and get the expected results:
  • -> convert 'input.pdf[2-5]' -scene 2 output.png

    -> ls out*
    output-2.png
    output-3.png
    output-4.png
    output-5.png

Re: Problems selecting frames

Posted: 2009-07-24T10:18:48-07:00
by fmw42
Neat! -scene is better than +adjoin as it keeps the resulting sequence properly numbered. Have to remember that.

Re: Problems selecting frames

Posted: 2009-07-24T12:09:21-07:00
by magick
We added a patch to the Subversion trunk so the -scene option is optional, that is, input.pdf[2-4] automatically creates output-2.pdf, output-3.pdf, etc.

Re: Problems selecting frames

Posted: 2009-08-05T23:15:32-07:00
by anthony
fmw42 wrote:Neat! -scene is better than +adjoin as it keeps the resulting sequence properly numbered. Have to remember that.

You misunderstand the default -adjoin is only used when writing to images that can handle multiple images into one file.

If the output file does not allow 'adjoin' such as PNG or JPEG, OR your give a %d type escape in the output filename, OR you specify "+adjoin" then IM then will output each image to separate files.

See IM Examples, Adjoin - Outputing Multiple Images
http://www.imagemagick.org/Usage/files/#adjoin

The -scene setting is separate. It does not touch the adjoin setting, all it does is specify the starting number when you output to multiple separate files.

See IM Examples, Scene, Starting Sequence Number
http://www.imagemagick.org/Usage/files/#scene

Final note. Whne using +adjoin, it is recommend you set the %d in the output filename as well to give the format of the number. For example always output 3 digit numbers you can use the filename.... image_%03d.png

Re: Problems selecting frames

Posted: 2009-08-06T07:14:18-07:00
by seedy
I had been using 6.5.4-2-Q16. I have upgraded to 6.5.4-9 and I continue to have the same problem

The command:

Code: Select all

convert "input.pdf[2-4]" -scene 2 output.png
Produces only a single output.png file. Could it be an issue with GhostScript ? I am on Ghostscript 8.64, Windows XP.

some more verbose output to compare

Code: Select all

convert -verbose input.pdf output.png
input.pdf=>output-0.png[0] PDF 611x395 611x395+0+0 16-bit DirectClass 272kb 0.297u 0:01
input.pdf=>output-1.png[1] PDF 611x395 611x395+0+0 16-bit DirectClass 432kb 0.484u 0:01
input.pdf=>output-2.png[2] PDF 611x395 611x395+0+0 16-bit DirectClass 624kb 0.813u 0:01
input.pdf=>output-3.png[3] PDF 611x395 611x395+0+0 16-bit DirectClass 640kb 1.203u 0:02
input.pdf=>output-4.png[4] PDF 611x395 611x395+0+0 16-bit DirectClass 592kb 1.500u 0:02
input.pdf=>output-5.png[5] PDF 614x393 614x393+0+0 16-bit DirectClass 672kb 1.891u 0:03
input.pdf=>output-6.png[6] PDF 611x395 611x395+0+0 16-bit DirectClass 416kb 2.094u 0:03
input.pdf=>output-7.png[7] PDF 611x395 611x395+0+0 16-bit DirectClass 512kb 2.313u 0:03
input.pdf=>output-8.png[8] PDF 305x395 305x395+0+0 16-bit DirectClass 128kb 2.406u 0:03

Code: Select all

convert -verbose input.pdf[3-5] output.png
input.pdf[3-5]=>output.png PDF 611x395 611x395+0+0 16-bit DirectClass 640kb 0.375u 0:01

Re: Problems selecting frames

Posted: 2009-08-06T09:37:29-07:00
by fmw42
magick wrote:We added a patch to the Subversion trunk so the -scene option is optional, that is, input.pdf[2-4] automatically creates output-2.pdf, output-3.pdf, etc.

This does not seem to work in IM 6.5.4-8 Q16 (HDRI)

convert rose: rose: rose: rose: rose: rose.pdf

convert rose.pdf[1-3] rose.png
makes rose-0.png, rose-1.png, rose-2.png

but

convert rose.pdf[1-3] -scene 1 rose.png
makes rose-1.png, rose-2.png, rose3.png

Re: Problems selecting frames

Posted: 2009-08-06T19:07:04-07:00
by anthony
WARNING; put the [2-4] in quotes. Otherwise the shell (bash) may interpret the [..] sequence itself as a filename selection, rather than just passing it to IM for selecting frames!!!!

Re: Problems selecting frames

Posted: 2009-08-06T19:56:48-07:00
by fmw42
anthony wrote:WARNING; put the [2-4] in quotes. Otherwise the shell (bash) may interpret the [..] sequence itself as a filename selection, rather than just passing it to IM for selecting frames!!!!

I still get the same results with or without quotes. If this has been fixed so that -scene is not needed, it is not working. IM 6.5.4-9 Q16 HDRI Mac OSX Tiger.

Re: Problems selecting frames

Posted: 2009-08-07T06:00:47-07:00
by seedy
I have tried without quotes, with quotes, and with quotes only around the [2-4]. They all have the result of a single output.png file.

Re: Problems selecting frames

Posted: 2009-08-07T07:06:09-07:00
by magick
We can reproduce the problem you posted and have a patch to fix it in the Subversion trunk, available sometime tomorrow. Thanks.

Re: Problems selecting frames

Posted: 2009-08-07T07:22:11-07:00
by seedy
Great! Thanks

Re: Problems selecting frames

Posted: 2009-08-19T08:22:35-07:00
by seedy
Did this patch make it into 6.5.4-10 ? I'm not sure where to check for a changelog.