Page 1 of 1
How to read the dpi resolution of an image
Posted: 2010-12-30T05:27:41-07:00
by hape
Been using IM for more than 10 years now as command line op called from php scripts.
Usually to convert and resize uploaded images, create thumbnails etc etc
Typical line - ("$CONVERT -geometry $himagesize -quality 95 $tmpname1 ".$M_IMAGES.$uniq_imageid."_1.jpg")
Lately users tend to upload high res images with 300 and above dpi.
Not a problem with my Firefox/LINUX ... but a problem for WIN users with IE. Depending on the version and the type of monitor they use, those hi res images are not displayed.
What I am trying to figure out is a new upload routine (just command line)
Read an uploaded image, get the dpi resolution and if not 72dpi convert to 72dpi while keeping the size in pixels.
Did not find a solution yet.
Any suggestion would be greatly appreciated.
Thanks for your help
Helmut
Re: How to read the dpi resolution of an image
Posted: 2010-12-30T11:04:35-07:00
by fmw42
see string formats %x and %y and use -density to convert
convert image -format "%x x %y" info:
But dpi should have no bearing on image display as the display only depends upon the pixel resolution (width and height). DPI is only used when printing. You can get the width and height similarly from
convert image -format "%w x %h" info:
Windows uses see
http://www.imagemagick.org/Usage/windows/
Re: How to read the dpi resolution of an image
Posted: 2010-12-31T01:51:55-07:00
by hape
Thanks. Will test it
Re: How to read the dpi resolution of an image
Posted: 2019-08-26T18:23:34-07:00
by Jimbo
Don't be too quick to dismiss dpi.
Photoshop, for example, has a built-in limitation. It can only correctly display images if the resulting x or y dimension in INCHES is less than 1000.
So, if you are using Photoshop as part of your process to completion, specifying dpi is vital to really large images. A dpi of 72 is rather small, and if the image is large 15K and above, you will be in some serious waiting to convert the result in Photoshop. Much better to use ImageMagick as long as it treats dpi correctly.
Currently, I have not found a way to change the density of an EXR image correctly using ImageMagick and Exr does support dpi for its header.
My input.exr image is 10240x4522 by 72dpi.
Here are the three calls I have tried this far to change an ex's dpi:
convert -density 180 input.exr output.exr
convert -units PixelsPerInch -density 180 input.exr output.exr
convert -units PixelsPerInch -density 180 -resize 10240 input.exr output.exr
None of them worked. The resulting output.exr image was the same as the input.
Thoughts? Suggestions?
Cheers.
- Jimbo
Re: How to read the dpi resolution of an image
Posted: 2019-08-26T18:27:22-07:00
by fmw42
All your command are wrong as I mentioned above. Changing the density before reading a raster image works for vector formats. You should specify a density after reading the input raster. Try
convert input.exr -units PixelsPerInch -density 180 output.exr
If that does not work, then ImageMagick has no method of affecting the writing of density to EXR.
The density should not affect the display of raster images. It only affects printing. I have no idea why Photoshop would limit the density on raster images. That might be meaningful for vector files, only.
Re: How to read the dpi resolution of an image
Posted: 2019-08-26T18:29:27-07:00
by fmw42
Do you have OpenEXR installed such that imagemagick can find it and report it in
Re: How to read the dpi resolution of an image
Posted: 2019-08-26T21:34:14-07:00
by fmw42
I do not see anything about density in the EXR documentation at
https://www.openexr.com/documentation/R ... eFiles.pdf