[Pkg-mozext-commits] [adblock-plus] 06/41: Issue 1883 - Work around another PIL bug by using RGBA insted LA
David Prévot
taffit at moszumanska.debian.org
Wed Mar 18 18:21:37 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository adblock-plus.
commit 2bd3aeb126c6ea2a6eee0deeb7489cf0a6d81c6b
Author: Sebastian Noack <sebastian at adblockplus.org>
Date: Tue Jan 27 17:10:23 2015 +0100
Issue 1883 - Work around another PIL bug by using RGBA insted LA
---
imageConversion.py | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/imageConversion.py b/imageConversion.py
index 87e9fec..6c32773 100644
--- a/imageConversion.py
+++ b/imageConversion.py
@@ -20,13 +20,14 @@ def get_alpha(image):
return image.split()[image.getbands().index('A')]
# In order to generate an alpha channel for images using a palette, we
- # convert the image to grayscale+alpha. Initially, we created an alpha
- # channel by replacing opaque pixels with a high mark and transparent
+ # convert the image to RGBA. It's important to use RGBA, not LA (grayscale+alpha),
+ # since PIL can't reliably convert P to LA. Also initially, we created an
+ # alpha channel by replacing opaque pixels with a high mark and transparent
# pixels with a low mark. However, it turned out that you can't rely on the
# value of Image.info['transparency'] since in some cases it might be an
# unparsed string instead an int indicating the value of transparent pixels.
if image.mode == 'P' and 'transparency' in image.info:
- return image.convert('LA').split()[1]
+ return image.convert('RGBA').split()[4]
def load_image(path):
image = Image.open(path)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git
More information about the Pkg-mozext-commits
mailing list