When converting or mogrify-ing images I’ve noticed grayscale PNG files are far darker than originals – mid-grays become almost black. It turns out ImageMagick tries to set to PNG8 based on image content even if the file was previously PNG24 or PNG32. This conversion is trigged by both convert and mogrify, e.g. image resizing with -geometry option.
The default format can be overridden in convert using either the FORMAT:output syntax or -define png:format=png24
convert input.ppm PNG24:output.png
For mogrify only the -define method works, -define png:format=png24
mogrify -define png:format=png24 -geometry x30 input.png output.png
I also tried solutions involving -colorspace RGB or -colorspace sRGB but files generated like this looked fine in GIMP etc. but were too light in firefox, chrome etc.