Apparently PIL saves PGM internally as PPM unless you convert the image to grayscale first. Add proper check for format to fix the issue (perhaps to imtools save?).
Here's a test case I used to verify this behavior: from Image import open
im = open('Lenna.png')
gim = im.convert('L') gim.save('Lenna1.pgm') im.save('Lenna2.pgm') im.save('Lenna3.ppm')
Apparently PIL saves PGM internally as PPM unless you convert the image to grayscale first. Add proper check for format to fix the issue (perhaps to imtools save?).
Here's a test case I used to verify this behavior:
from Image import open
im = open('Lenna.png')
gim = im.convert('L') 'Lenna1. pgm') 'Lenna2. pgm') 'Lenna3. ppm')
gim.save(
im.save(
im.save(