This is what I get on IM 6.8.0.3 Q16 Mac OSX Snow Leopard
convert test.ppm txt:
# ImageMagick pixel enumeration: 8,1,255,srgb
0,0: ( 0, 0, 0) #000000 black
1,0: ( 32, 32, 32) #202020 srgb(32,32,32)
2,0: ( 64, 64, 64) #404040 grey25
3,0: ( 96, 96, 96) #606060 srgb(96,96,96)
4,0: (128,128,128) #808080 fractal
5,0: (160,160,160) #A0A0A0 srgb(160,160,160)
6,0: (192,192,192) #C0C0C0 silver
7,0: (224,224,224) #E0E0E0 grey88
PPM I believe is linear for grayscale and PNG will be non-linear sRGB. So I think it is a colorspace issue, since after IM 6.7.8.3 grayscale was treated as linear see
viewtopic.php?f=4&t=21269 and
http://www.imagemagick.org/script/forma ... colorspace
This gives the wrong results due to the linear to sRGB conversion:
convert test.ppm -set colorspace RGB test.png
convert test.png txt:
# ImageMagick pixel enumeration: 8,1,255,srgb
0,0: ( 0, 0, 0) #000000 black
1,0: ( 4, 4, 4) #040404 srgb(4,4,4)
2,0: ( 13, 13, 13) #0D0D0D grey5
3,0: ( 30, 30, 30) #1E1E1E srgb(30,30,30)
4,0: ( 55, 55, 55) #373737 srgb(55,55,55)
5,0: ( 90, 90, 90) #5A5A5A srgb(90,90,90)
6,0: (134,134,134) #868686 srgb(134,134,134)
7,0: (190,190,190) #BEBEBE grey
But by forcing the conversion to to PNG to think it is already linear, then it won't make the PNG sRGB. Do that by adding -set colorspace RGB.
This gives the same result as the PPM
convert test.ppm
-set colorspace RGB test.png
convert test.png txt:
# ImageMagick pixel enumeration: 8,1,255,gray
0,0: ( 0, 0, 0) #000000 gray(0,0,0)
1,0: ( 32, 32, 32) #202020 gray(32,32,32)
2,0: ( 64, 64, 64) #404040 gray(64,64,64)
3,0: ( 96, 96, 96) #606060 gray(96,96,96)
4,0: (128,128,128) #808080 gray(128,128,128)
5,0: (160,160,160) #A0A0A0 gray(160,160,160)
6,0: (192,192,192) #C0C0C0 gray(192,192,192)
7,0: (224,224,224) #E0E0E0 gray(224,224,224)
As to whether this is a bug or not, the IM developers would need to respond.