mirror of
https://github.com/kemayo/leech
synced 2026-01-03 14:14:24 +01:00
fix: Fixes bad transparency mask error
This commit is contained in:
parent
2ef94412b4
commit
c96f3d15c0
1 changed files with 6 additions and 1 deletions
|
|
@ -63,7 +63,12 @@ def PIL_Image_to_bytes(
|
|||
return out_io.getvalue()
|
||||
|
||||
elif image_format.lower() in ["jpeg", "jpg"]:
|
||||
pil_image = pil_image.convert("RGB")
|
||||
# Create a new image with a white background
|
||||
background_img = Image.new('RGBA', pil_image.size, "white")
|
||||
|
||||
# Paste the image on top of the background
|
||||
background_img.paste(pil_image.convert("RGBA"), (0, 0), pil_image.convert("RGBA"))
|
||||
pil_image = background_img.convert('RGB')
|
||||
|
||||
pil_image.save(out_io, format=image_format, optimize=True, quality=95)
|
||||
return out_io.getvalue()
|
||||
|
|
|
|||
Loading…
Reference in a new issue