diff --git a/imagekit/utils.py b/imagekit/utils.py index 637433e..2c72185 100644 --- a/imagekit/utils.py +++ b/imagekit/utils.py @@ -10,10 +10,11 @@ def img_to_fobj(img, format, **kwargs): tmp = tempfile.TemporaryFile() # Preserve transparency if the image is in Pallette (P) mode. - if img.mode == 'P': + transparency_formats = ('PNG', 'GIF', ) + if img.mode == 'P' and format in transparency_formats: kwargs['transparency'] = len(img.split()[-1].getcolors()) else: - img.convert('RGB') + img = img.convert('RGB') img.save(tmp, format, **kwargs) tmp.seek(0)