Setting the size in resize to print an image 6"x4"


The sizes used in ImageMagick are in pixels; to get an image into a size for printing e.g. 6"x4" you need to do something like this:

<?php
exec
("convert input.jpg -resize 600x400 -density 100x100 output.jpg");
?>
  • The default pixel value in ImageMagick is DPI ( dots per inch ) so that will not need setting.
  • The -density sets the pixels per inch; you can have a different value for the height and width if required
  • The values in -resize are set by multiplying the required size by the DPI:
    6 x 100 = 600 and 4 x 100 = 400
  • If you were working on 300 dpi it would be 6 x 300 = 1800 and 4 x 300 = 1200