From d3d0ab9c63a27347f4f21ac5d0ca09aec1d8936e Mon Sep 17 00:00:00 2001 From: moosecrap Date: Wed, 22 Jul 2026 23:02:48 -0700 Subject: [PATCH] Alignment and JPEG --- tools/contact_sheet.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/contact_sheet.py b/tools/contact_sheet.py index dbca8cf..f5fe885 100644 --- a/tools/contact_sheet.py +++ b/tools/contact_sheet.py @@ -95,7 +95,8 @@ async def handle(args: Dict[str, Any]): else: text_w, text_h = len(text) * 8, 15 - draw.rectangle([x, y + thumb_size - text_h - 5, x + text_w + 5, y + thumb_size - 2], fill=(0, 0, 0, 180)) + # Adjusted black box to align perfectly with the bottom of the image (y + thumb_size) + draw.rectangle([x, y + thumb_size - text_h - 4, x + text_w + 5, y + thumb_size], fill=(0, 0, 0, 180)) draw.text((x + 2, y + thumb_size - text_h - 7), text, fill=(255, 255, 255), font=font) except Exception as e: @@ -103,7 +104,8 @@ async def handle(args: Dict[str, Any]): draw.text((x + 5, y + thumb_size // 2), "Error", fill=(255, 0, 0), font=font) buf = io.BytesIO() - canvas.save(buf, format='PNG') + # Save as JPEG quality 95 to save data + canvas.save(buf, format='JPEG', quality=95) img_data = base64.b64encode(buf.getvalue()).decode("utf-8") total_pages = (total_files + PAGE_SIZE - 1) // PAGE_SIZE @@ -129,5 +131,5 @@ async def handle(args: Dict[str, Any]): return [ {"type": "text", "text": header_text}, - {"type": "image", "data": img_data, "mimeType": "image/png"} + {"type": "image", "data": img_data, "mimeType": "image/jpeg"} ]