Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: imageConversion.py

Issue 5195120659922944: Issue 1883 - Convert mode P to LA to work around a PIL bug when extracting the alpha channel (Closed)
Patch Set: Single quotes for consistency Created Jan. 27, 2015, 2:19 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: imageConversion.py
===================================================================
--- a/imageConversion.py
+++ b/imageConversion.py
@@ -16,17 +16,10 @@
import ImageOps
def get_alpha(image):
kzar 2015/01/27 14:25:42 I think there should be a comment here to explain
Sebastian Noack 2015/01/27 14:29:25 Frankly, converting an image without alpha channel
Sebastian Noack 2015/01/27 15:10:05 It's unneeded to document APIs in the calling code
- if image.mode in ('RGBA', 'LA'):
- return image.split()[image.getbands().index('A')]
+ if image.mode not in ('RGBA', 'LA'):
+ image = image.convert('LA')
- if image.mode == 'P':
- transparency = image.info.get('transparency')
-
- if transparency is not None:
- table = [255] * 256
- table[transparency] = 0
-
- return image.point(table, 'L')
+ return image.split()[image.getbands().index('A')]
def load_image(path):
image = Image.open(path)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld