Determining DPI through ImageMagick

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
ziasumo

Determining DPI through ImageMagick

Post by ziasumo »

Is ImageMagick calculate DPI of an image correctly for all format images like (jpeg, tiff, bmp)?
May I increase/decrease DPI of an image through ImageMagick?
in this command
identify -verbose some_image.jpg
In the output where is DPI?
ziasumo

Re: Determining DPI through ImageMagick

Post by ziasumo »

Hi Buddies
I found the solution...

identify -format "%w x %h %x x %y" image.jpg
216 x 144 72 PixelsPerInch x 72 PixelsPerInch

Adjust the DPI:

convert image.jpg -units "PixelsPerInch" -density 300 -resample "300x" image300.jpg

Check the properties of the new file:

identify -format "%w x %h %x x %y" image300.jpg
216 x 144 300 PixelsPerInch x 300 PixelsPerInch

It works fine for me.
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Determining DPI through ImageMagick

Post by Drarakel »

When you first change the density manually to 300dpi, you don't need the "-resample". :wink:
ziasumo

Re: Determining DPI through ImageMagick

Post by ziasumo »

Thanks but can you tell me will it effect the quality of image in printing..?
Drarakel
Posts: 547
Joined: 2010-04-07T12:36:59-07:00
Authentication code: 8675308

Re: Determining DPI through ImageMagick

Post by Drarakel »

ziasumo wrote:Thanks but can you tell me will it effect the quality of image in printing..?
What is "it"?

- In your example, the resample does simply nothing.
- Changing the density doesn't alter the quality of the image (the pixels) itself - but it will change the print size. When you change the density of a file from 72 to 300 dpi, it will usually be printed at a smaller size - if that's what you want. (The print could 'look' better if it's on a smaller size.)
- Changing the density with ImageMagick and storing it as JPG does affect/reduce the quality of the image - as it has to recompress the file (but the difference will usually be very small).
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Determining DPI through ImageMagick

Post by anthony »

For all the details abour image density or resolution in ImageMagick see..

Basics, Image Density or Resolution
http://www.imagemagick.org/Usage/basics/#density

Resizing images, Resample - Changing an image's resolution
http://www.imagemagick.org/Usage/resize/#resample
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply