Older ImageMagick solutions often suggest using -units PixelsPerInch
when changing the density of a PNG image, that is, for example, -units PixelsPerInch -density 300
, and not just -density 300
.
But in modern ImageMagick (7.1.1-33), according to the following tests, -units PixelsPerInch
seems to be no longer needed for this. Is it really so or I misunderstood something?
Step 1
magick identify -format %xx%y a.png => 72x72
magick identify -units PixelsPerInch -format %xx%y a.png => 72x72
Step 2
magick a.png -density 300 a1.png
magick a.png -units PixelsPerInch -density 300 a2.png
Step 3
magick identify -format %xx%y a1.png => 300x300
magick identify -units PixelsPerInch -format %xx%y a1.png => 300x300
Step 4
magick identify -format %xx%y a2.png => 300x300
magick identify -units PixelsPerInch -format %xx%y a2.png => 300x300
PNG units are always converted to equivalent pixelspercentimeters if the units are properly specified when specifying the density and not labeled "unspecified". So for example
magick identify -format %xx%y-%U lena.png
72x72-Undefined
magick lena.png -units pixelsperinch -density 72x72 x.png
magick identify -format %xx%y-%U\n x.png
28.339999999999999858x28.339999999999999858-PixelsPerCentimeter
Your issues is likely that the units are unspecified and you are trying to change them in a magick identify, which likely ignores the -units argument. When the units are unspecified, the density or resolution shows 72x72.