Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm on Ubuntu 10.04 with imagemagick. I used this command:

convert myfile.pdf -density 300 file.jpg

This works well, but the JPGs are only about an inch high. How can I preserve the paper size in the conversion process?

share|improve this question
It might be easier to give a good answer if you give more background, e.g. why you want to do the conversion you describe, what material you are working with and quality you need from results. – N.N. Oct 28 '11 at 7:01

You can set the -density before you read the source pdf, so you can do

convert -density 300 myfile.pdf myfile.jpg

and it'll read the pdf at 300dpi, then render out the jpg at the original size of the pdf, whatever that was.

share|improve this answer

I don't know if Imagemagick can sense the correct height automatically. However if you can come up with the correct height in pixel you can set the height manually.

According to an A4 paper has the height of 3508 pixels in 300 dpi so then you can do

convert myfile.pdf -density 300 -geometry x3508 file2.jpg

This command sets the width to 3508 pixels and preserves aspect radio. See for details on the -geometry argument.

share|improve this answer
Thank you! that works well. I'm using this to automate a scribus publishing project. – Trude Oct 31 '11 at 13:36
I'm glad it works. If you find an answer helpful you should vote it up by clicking the upward pointing arrow to the left of the answer. Also, you should consider to accept the most helpful answer by marking it as the accepted answer by clicking on the check box outline to the left of the answer. See faq for details. – N.N. Oct 31 '11 at 14:30
For better quality, you should set density BEFORE the input file name, like "convert -density 300 myfile.pdf file2.jpg". Then ImageMagick uses this resolution to rasterize the PDF. Otherwise it will rasterize the PDF at a default resolution (72 dpi) and the -geometry command scales up the already rasterized image. The -density command after the input file name only modifies the EXIF property of the output file, not its pixels. (As a bonus, if you specify -density before the input file name, you don't need -geometry any more to preserve the image size.) – Jaan Sep 23 '14 at 12:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .