1 parent
1ec445dbb1
commit
d4248499ca
2 files changed
+8
-2
No files matched your search
@@ -170,7 +170,10 @@ class ImageMixin(_ImageMixin):
|
||||
img = PIL.Image.open(io.BytesIO(image))
|
||||
img.thumbnail((SIZE_MAX, SIZE_MAX))
|
||||
if img.mode in {'RGBA', 'P'}:
|
||||
img = img.convert('RGB')
|
||||
img.convert('RGBA')
|
||||
background = PIL.Image.new('RGBA', img.size, (255, 255, 255))
|
||||
background.alpha_composite(img)
|
||||
img = background.convert('RGB')
|
||||
img.save(data, format='jpeg', optimize=True, **_params)
|
||||
return data.getvalue()
|
||||
|
||||
|
||||
@@ -129,7 +129,10 @@ class Avatar(ImageMixin, ResourceMixin, ModelSQL):
|
||||
if size > 2048:
|
||||
img = img.resize((2048, 2048))
|
||||
if img.mode in {'RGBA', 'P'}:
|
||||
img = img.convert('RGB')
|
||||
img.convert('RGBA')
|
||||
background = Image.new('RGBA', img.size, (255, 255, 255))
|
||||
background.alpha_composite(img)
|
||||
img = background.convert('RGB')
|
||||
img.save(data, format='jpeg', optimize=True, **_params)
|
||||
return data.getvalue()
|
||||
|
||||
|
||||
Reference in new issue
Block a user