PIL bug workaround

This commit is contained in:
Matthew Tretter 2012-04-19 23:59:20 -04:00
parent 6f8a22c5bf
commit 5fdf9d6a91

View file

@ -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,