From e9821edd94020865736327e4452de566b2995868 Mon Sep 17 00:00:00 2001 From: brightpisces Date: Tue, 24 Jun 2014 15:34:43 +0800 Subject: [PATCH] Match real palette format in ImagePalette.save() --- PIL/ImagePalette.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/PIL/ImagePalette.py b/PIL/ImagePalette.py index d5b9d04eb..3496b99df 100644 --- a/PIL/ImagePalette.py +++ b/PIL/ImagePalette.py @@ -101,8 +101,11 @@ class ImagePalette: fp.write("# Mode: %s\n" % self.mode) for i in range(256): fp.write("%d" % i) - for j in range(i, len(self.palette), 256): - fp.write(" %d" % self.palette[j]) + for j in range(i*3, i*3+3): + try: + fp.write(" %d" % self.palette[j]) + except IndexError: + fp.write(" 0") fp.write("\n") fp.close()