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?
The resolution and units used are stored in the file, so if the resolution is stored in PixelsPerCentimeter, that’s how
identifywill display it. There isn’t a way to do the conversion automatically throughidentify. But it’s just cm to inch conversion math: