Running this gives the geometry but not the density:
$ identify -verbose myfile.pgm | grep -iE 'geometry|pixel|dens|size|dimen|inch|unit'
There is also a “Pixels per second” attribute which means nothing to me. No density and not even a canvas/page dimension (which would make it possible to compute the density). The “Units” attribute on my source images are “undefined”.
Suggestions?
If I’m not mistaken, ImageMagick doesn’t know the canvas size or printer you’ll be using. It only knows the height and width in pixels.
The pgm format doesn’t seem to have an attribute for ppi https://netpbm.sourceforge.net/doc/pgm.html