Resizing a PDF with landscape pages creates errors

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
virtual

Resizing a PDF with landscape pages creates errors

Post by virtual »

Hi all,

I'm not sure if I'm going about this in the right way, I'll explain my needs:

1. I need all the output images in a common format (standard A4 size)
2. Any sized PDF should be created using the above format.
3. I don't know, when using ImageMagick, whether the PDF will contain landscaped or other strange format pages.

The code I am using is:

Code: Select all

exec("convert input.pdf -resize 475x670! -strip -quality 90 output.jpg");
Now, when I convert portrait PDF's into this format it works great. However, one can also use landscape PDF's, or other strange shapes: Here's what it looks like:

- http://i50.tinypic.com/35n80me.jpg

Am I doing something wrong, or is there another way I should be doing this?

Thanks all, I'm kind of stuck with this one!

Edit: Oops, here is an example of the PDF I'm using to test: http://jump.fm/OBURI
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Resizing a PDF with landscape pages creates errors

Post by anthony »

You could use -resize 670x670 which will fit the image into a box of that size. That is only the longest dimension becomes 670 pixel long. The other dimension is adjusted to best preserve the images aspect ratio.

The other method is ensure the image is portrait but doing a conditional rotate -rotate -90\> before the resize.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply