From 5fdf9d6a91074ef41147eea9fd9767556368d2e0 Mon Sep 17 00:00:00 2001 From: Matthew Tretter Date: Thu, 19 Apr 2012 23:59:20 -0400 Subject: [PATCH] PIL bug workaround --- imagekit/processors/base.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/imagekit/processors/base.py b/imagekit/processors/base.py index afc0f4f..1be6736 100644 --- a/imagekit/processors/base.py +++ b/imagekit/processors/base.py @@ -208,6 +208,11 @@ class AutoConvert(object): # In other words, a P-format image converted to an # RGBA-formatted image by a processor and then saved as a # P-format image will give the expected results. + + # Work around a bug in PIL: split() doesn't check to see if + # img is loaded. + img.load() + alpha = img.split()[-1] mask = Image.eval(alpha, lambda a: 255 if a <= 128 else 0) img = img.convert('RGB').convert('P', palette=Image.ADAPTIVE,