changing DPI

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
ewok251

changing DPI

Post by ewok251 »

Hi.

I want to change the DPI of an image, but it doesnt seem to be working.
I don't want to change the number of pixels, just the size that it's rendered at, so im using -density not -resample. However:

Code: Select all

$ identify -format "%x x %y" img_0359.jpg 
180 PixelsPerInch x 180 PixelsPerInch
$ mogrify -density 72x72 img_0359.jpg 
$ identify -format "%x x %y" img_0359.jpg 
180 PixelsPerInch x 180 PixelsPerInch
Same thing happens with 'convert' too.

The mogrify must be doing something, because if I load it into the GIMP it says the resolution is 72x72, but previewer on the Mac shows 180x180, and an 'identify -verbose' shows 180x180 and no mention of 72x72 anywhere.

Ive tried it on several images from several sources, all the same result. Ive stripped out any profile that might be used by Photoshop just in case.

Am I making some fundamental mistake?

thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: changing DPI

Post by fmw42 »

It works for me.

convert rose: rose.jpg
identify -format "%x x %y" rose.jpg
72 PixelsPerInch x 72 PixelsPerInch

convert rose.jpg -density 180 rose2.jpg
identify -format "%x x %y" rose2.jpg
180 PixelsPerInch x 180 PixelsPerInch

convert rose2.jpg -density 72 rose3.jpg
identify -format "%x x %y" rose3.jpg
72 PixelsPerInch x 72 PixelsPerInch

I am on IM 6.4.1-2beta Q16-hdri
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: changing DPI

Post by anthony »

Your JPG may be using photoshop densitys rather that the 'normal JPEG format density settings.

It also could be your IM is too old.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
ewok251

Re: changing DPI

Post by ewok251 »

an update on how I resolved this.. first I think I was just using a too old version of IM, but secondly, Photoshop seems to divide DPI by 10000 for some reason, so for example to get Photoshop to see 300dpi, I needed to do -density 3000000
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: changing DPI

Post by anthony »

try defining the -units setting as well as -density
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: changing DPI

Post by anthony »

What operation changes the DPI? Neither resize or crop should do this.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply