From 232c175bd92320100f891d0d9874cf8230a19b1b Mon Sep 17 00:00:00 2001 From: David Schmidt Date: Wed, 5 Feb 2014 12:49:06 +0100 Subject: [PATCH] fixes #513 --- PIL/PngImagePlugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PIL/PngImagePlugin.py b/PIL/PngImagePlugin.py index a6038d9f2..30fdfb8ac 100644 --- a/PIL/PngImagePlugin.py +++ b/PIL/PngImagePlugin.py @@ -505,7 +505,7 @@ def _save(im, fp, filename, chunk=putchunk, check=0): else: # check palette contents if im.palette: - colors = len(im.palette.getdata()[1])//3 + colors = max(len(im.im.getpalette("RGB"))//3, 256) else: colors = 256