Hello Team,
Can anyone please let me know how can I get the image resolution (DPI) with the units also for the PNG / BMP images?
I am using the below command but it is giving me DPI in PixelPerCentimeter and I need the unit in PixelPerInches.
exec("identify -format '%x' -units 'PixelsPerInch' jeanrightleg.png")
It was working for ImageMagick 6.7 but when I upgraded the ImageMagick version to 7.0.8 then it is not works as expected.
I am using CentOS 7.6
ImageMagick 7.0.8
Below is the image URL.
https://www.dropbox.com/s/0jga5x4d9qcaa ... g.png?dl=0
Thanks in advanced.
How to get Image DPI in PixelPerInches
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: How to get Image DPI in PixelPerInches
It seems to work for me, with v7.0.7-28 on Windows 8.1:
Code: Select all
f:\web\im>%IMG7%magick identify -format '%x' -units PixelsPerInch jeanrightleg.png
'72.010000000000005'
f:\web\im>%IMG7%magick identify -format '%x' jeanrightleg.png
'28.350000000000001'
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: How to get Image DPI in PixelPerInches
For me on IM 7.0.8.23 Q16 Mac OSX, the image shows no Resolution and undefined units using
So I presume Imagemagick assumes 72 dpi (converted to dpc for png).
But when I do that command, I get 72 both times.
This would be a change and bug if it indeed worked in previous versions.
Code: Select all
magick identify -verbose image.png
But when I do that command, I get 72 both times.
Code: Select all
magick identify -format '%x' -units PixelsPerInch image.png
72
magick identify -format '%x' image.png
72