Page from PDF passed through stdin

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
whirled

Page from PDF passed through stdin

Post by whirled »

Hi,

I have a PHP script that generates a PDF document, then places that PDF into a string to pass to convert as stdin.

These PDFs are press quality, so they tend to be rather large. In order to show the user a low resolution GIF or JPG image I use the following command:

Code: Select all

convert -density 305 -resize 100% -profile 'USWebCoatedSWOP.icc' pdf:-[page#] -profile 'sRGB Color Space Profile.icm' -resample 72 gif:-
where page# is the page I want from the PDF.

This works fine if I only want the first page. If I do not specify a page, it returns the last page. My problem is that when I try to get a page other than the first or last, or I enter the last pages page number, I get an error.

Does anyone know if it is possible to specify the PDF page to convert if the PDF is passed through stdin? I would like to avoid using the PHP API for now if I can. However, I will be forced if someone knows if I can do what I need with the API, and not from the command line.

Any help with this would be greatly appreciated.

Thanks,
whirled

Re: Page from PDF passed through stdin

Post by whirled »

I figured out what I was doing wrong, so I will post a reply to let anyone else who has this problem what I did wrong.

The page number should be specified after the output file, not the input file as I was doing.

Example:

Code: Select all

convert -density 305 -resize 100% -profile 'USWebCoatedSWOP.icc' pdf:- -profile 'sRGB Color Space Profile.icm' -resample 72 gif:-[page#]
Post Reply