Merge pull request #52 from islavov/patch-1

FIX: RGBA mode breaks transparency check
This commit is contained in:
Matthew Tretter 2011-11-05 11:55:10 -07:00
commit 7ab1d08e49

View file

@ -12,8 +12,9 @@ def img_to_fobj(img, format, **kwargs):
# Preserve transparency if the image is in Pallette (P) mode.
transparency_formats = ('PNG', 'GIF', )
if img.mode == 'P' and format in transparency_formats:
kwargs['transparency'] = len(img.split()[-1].getcolors())
if format in transparency_formats:
if img.mode == 'P':
kwargs['transparency'] = len(img.split()[-1].getcolors())
else:
img = img.convert('RGB')