Convert gray PPM to PGM, PNG
Posted: 2012-11-01T10:33:05-07:00
ImageMagick 6.7.7-10 on Ubuntu 12.10 x86_64.
There is a gray PPM image 8x1 "00 20 40 60 80 a0 c0 e0"
ppmtopgm converts correctly from PPM to PGM: "00 20 40 60 80 a0 c0 e0"
When converting this PPM image using ImageMagick the result is wrong: "00 04 0d 1e 37 5a 86 be"
The same problem exists with the convertion from PPM to PNG and back: "00 04 0d 1e 37 5a 86 be"
There is a gray PPM image 8x1 "00 20 40 60 80 a0 c0 e0"
Code: Select all
$ cat test.ppm
P3
8 1
255
0
0
0
32
32
32
64
64
64
96
96
96
128
128
128
160
160
160
192
192
192
224
224
224
Code: Select all
$ ppmtopgm test.ppm | hexdump -C
00000000 50 35 0a 38 20 31 0a 32 35 35 0a 00 20 40 60 80 |P5.8 1.255.. @`.|
00000010 a0 c0 e0 |...|
00000013
Code: Select all
$ convert test.ppm pgm: | hexdump -C
00000000 50 35 0a 38 20 31 0a 32 35 35 0a 00 04 0d 1e 37 |P5.8 1.255.....7|
00000010 5a 86 be |Z..|
00000013
Code: Select all
$ convert test.ppm png: | convert - ppm: | hexdump -C
00000000 50 36 0a 38 20 31 0a 32 35 35 0a 00 00 00 04 04 |P6.8 1.255......|
00000010 04 0d 0d 0d 1e 1e 1e 37 37 37 5a 5a 5a 86 86 86 |.......777ZZZ...|
00000020 be be be |...|
00000023