I'm trying to create an image using imagemagick's "convert".

I have this command:

convert -size 720x480 xc:white -units pixelsperinch -density 81x72 foo.jpg

However, the image ends up with a 72x72 resolution, rather than 81x72.

identify -verbose foo.jpg
Image: foo.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Class: PseudoClass
  Geometry: 720x480+0+0
  Resolution: 72x72
  Print size: 10x6.66667

When I run convert with -resample 81x72 rather than -density, I get the correct resolution. Why is this?


-density is not for resizing. From the ImageMagick page on density:

The -density option sets an attribute and does not alter the underlying raster image. It may be used to adjust the rendered size for desktop publishing purposes by adjusting the scale applied to the pixels. To resize the image so that it is the same size at a different resolution, use the -resample option.

-resample is just a simple wrapper around the -resize switch.

  • Cool, I didn't quite realize that it was just "modifying some arbitrary header" rather than actually setting the size; thank you for pointing out that part of the doc! – rascher Dec 26 '09 at 3:22
  • You're welcome! happy holidays :) – John T Dec 26 '09 at 3:22
  • Hm, one more question: when I change to "resample", it changes the dimensions of my image (to 810x480). Do you know what I need to do to create an image which forces both my desired DPI and the desired dimensions? – rascher Dec 26 '09 at 3:30
  • Not even -size 720x480! (with the exclamation point!) does the trick. – rascher Dec 26 '09 at 3:35
  • 720x480 with 72 DPI? what is -density 72 -size 720x480 giving you? and with -resample 720x480? – John T Dec 26 '09 at 3:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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