skip to Main Content

I am using ImageMagick to reduce the image resolution, height and width.

I have noticed a few things. When I am changing resolution at “Image Size” through Photoshop (version 7) from 300dpi to 150dpi image height and width automatically change.

With ImageMagick however I am not getting such variations. For example, if image contains 878 width and 179 height at 300dpi, when changing it to 150 dpi, automatically the image width changing to 439 and height 89 respectively.

Can any one support me how to obtain such changes through ImageMagick.

2

Answers


  1. The dpi setting is not really relevant in most imaging applications/areas, until the point at which you want to print an image.

    Do you really need to set it? I mean, if you want to half the size of an image, just use ImageMagick and do:

    convert input.jpg -resize 50x50% output.jpg
    

    and ignore the dpi.

    Login or Signup to reply.
  2. To resize the image keeping the rendered size the same, you can use the -resample
    option, like so:

    $ convert original.jpg -resample 150x150 new.jpg
    

    Using your example, if the original is an 878×179 image at 300DPI,
    the result is an 439×90 image at 150DPI:

    $ file original.jpg
    original.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 300x300,
                  segment length 16, baseline, precision 8, 878x179, frames 3
    $ file new.jpg
    new.jpg: JPEG image data, JFIF standard 1.01, aspect ratio, density 150x150,
             segment length 16, baseline, precision 8, 439x90, frames 3
    

    You can alternatively use the
    -density
    option along with the
    -resize
    option to achieve the same effect:

    $ convert original.jpg -density 150x150 -resize 50%x50% new.jpg
    

    In summary:

    • -density
      just sets the DPI metadata without changing the underlying image;
    • -resize
      changes the image size without changing the DPI;
    • -resample
      changes the DPI and resizes the image accordingly.

    Uses

    The DPI metadata is relevant when you need to print an image or convert it to a PDF.

    Now you can convert both images to PDF and get files with essentially the same page size:

    $ convert original.jpg original.pdf
    $ convert new.jpg new.pdf
    $ pdfinfo original.pdf  | grep -a "Page size:"
    Page size:      210.72 x 42.96 pts
    $ pdfinfo new.pdf | grep -a "Page size:"
    Page size:      210.72 x 43.2 pts
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search