I can get PPI for a JPEG image using the following command:
$ identify -format "%w x %h %x x %y" mypic.jpg
1600 x 1200 72 PixelsPerInch x 72 PixelsPerInch
However, when I run the same command on PNG format I get Pixels Per Centimeter:
$ identify -format "%w x %h %x x %y" mypic.png
1600 x 1200 28.35 PixelsPerCentimeter x 28.35 PixelsPerCentimeter
Is there a way to change the command to get Pixels Per Inch (PPI) for PNG format as well or perhaps calculate the PPI based on the pixels per centimeter?
You can simply add the option
-units PixelsPerInch
The resolution and units used are stored in the file, so if the resolution is stored in PixelsPerCentimeter, that's how identify
will display it. There isn't a way to do the conversion automatically through identify
. But it's just cm to inch conversion math:
PixelsPerInch = PixelsPerCentimeter * 2.54
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With