mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-04-04 14:00:24 +00:00
RGBA is a transparent image mode too . When saving RGBA, you cannot specify 'transparency' color - you get IOError wrong mode.
This commit is contained in:
parent
3fd2450e8d
commit
ae8a3b8ef8
1 changed files with 3 additions and 2 deletions
|
|
@ -11,8 +11,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')
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue