fix: Flatten RGBA images before printing
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
5
main.py
5
main.py
@@ -31,6 +31,11 @@ def print_picture(filename, p):
|
||||
|
||||
img = Image.open(io.BytesIO(response.content))
|
||||
|
||||
if img.mode == 'RGBA':
|
||||
bg = Image.new('RGB', img.size, (255, 255, 255))
|
||||
bg.paste(img, mask=img.split()[3])
|
||||
img = bg
|
||||
|
||||
# Convert with dithering
|
||||
img = img.convert('1', dither=Image.FLOYDSTEINBERG)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user