fix: Flatten RGBA images before printing

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2025-12-09 21:34:56 -07:00
parent 259cb0cf1d
commit 6ff5f33ba1

View File

@@ -31,6 +31,11 @@ def print_picture(filename, p):
img = Image.open(io.BytesIO(response.content)) 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 # Convert with dithering
img = img.convert('1', dither=Image.FLOYDSTEINBERG) img = img.convert('1', dither=Image.FLOYDSTEINBERG)