Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

When I run

convert example.pdf example.png

I get a png image, but the image in the pdf is off-center and too small. How do I convert so that the png image is the right size and takes the whole page?

Actually, this conversion is an automatic feature of an Elog that I use. If I do end up altering the call to convert, I need to do it programatically so the image orientation is detected and the correct options applied.

When doing this with portrait-oriented images, it works fine.

example.pdf: https://www.dropbox.com/s/d8k2odc384tixzb/example.pdf

example.png: ExamplePNG

share|improve this question
Sorry, I can't post the images directly, until I have 10 rep, I guess. – reasgt Jun 28 '13 at 18:59
up vote 2 down vote accepted

I think you are looking for the -trim option:

     -trim                trim image edges

You can use it like this:

convert -trim -background black example.pdf example.png

To get this image:

enter image description here

The image above takes up the whole page, save it and open it locally to see it correctly.

share|improve this answer
Also the -density option for resolution. Might also require repage after trimming. – frostschutz Jun 28 '13 at 20:09
Yep, that works. Any idea why imagemagick does the conversion so poorly by default? – reasgt Jun 30 '13 at 22:38

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.