Changing resolution with -resample or -units density

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
joshua01
Posts: 4
Joined: 2017-03-29T01:45:50-07:00
Authentication code: 1151

Changing resolution with -resample or -units density

Post by joshua01 »

Hello,
I have image with resolution 600x600 (inches) with image width 2899 and image lenght 2081. Because of the next processes, where the system accepts only image with resolution of 300x300 i have to resample the original image. I know i can do it with two commands:

convert -units PixelsPerInch image -density 300 resultimage

convert image -resample 300x300 resultimage

I understand the command with resample, the resulted image has resolution 300 and image width and length in pixels are half of the original image.

But i the first command i am not sure wht it does, it changes the resolution but the image width and lenght is the same, i am not sure how to undertand this, what it does with the image.
Which command should i use if the only thing i want to change is the resolution just to pass it through the system, otherwise i want the image to be unchanged, as original image.
I tried to google it, but cant understand it fully.

Edit: The density option, if i understand it well, is said just to change the value of the tag not the real resolution, so the resolution is still 600 while the image metadata says it is 300? So what is better? What preserve image in better quality?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Changing resolution with -resample or -units density

Post by fmw42 »

If you multiply the density by the width and height in pixels, then you get the print size in inches. So it depends upon what print size you want. The use of -resample will preserve the print size in inches because it changes the width and height in pixels according to the change in density to match the print size. The use of just -density with make the print size change because you are changing the density but not the width and height in pixels.
Post Reply