thats-me/dev/tools/lifeline-images/contact_sheet.py
Kevin Adametz 10251e4f41 Doku und Werkzeuge: Tickets, Audit, Logos, Playwright-MCP
- dev/: Ticketliste, Audit und Vorschläge vom 17.09., Logo-SVGs,
  Lifeline-Bildwerkzeuge.
- AGENTS.md auf den aktuellen Stand (syncQueue statt syncService, kein
  legacy-Ordner mehr).
- .codex/ und __pycache__/ ignoriert; Playwright-MCP in .mcp.json.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-25 07:00:35 +00:00

22 lines
1.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env python3
"""Build a local contact sheet (HTML) for a lifeline's generated images."""
import base64, html, json, os, sys
handle = sys.argv[1]
data = json.load(open(f'/workspace/backend/database/data/lifelines/{handle}.json', encoding='utf-8'))
d = f'/workspace/backend/storage/app/private/lifeline-images/{handle}'
MON = ['','Jan','Feb','Mär','Apr','Mai','Jun','Jul','Aug','Sep','Okt','Nov','Dez']
cards = []
for e in data['events']:
slug = f"{e['age']:02d}-{e['month']:02d}"
p = f'{d}/{slug}.preview.jpg'
year = data['person']['birthYear'] + e['age']
img = f'<img src="data:image/jpeg;base64,{base64.b64encode(open(p,"rb").read()).decode()}">' if os.path.exists(p) else '<div class="missing">kein Bild</div>'
cards.append(f'<figure><div class="img">{img}</div><figcaption><b>{slug} · {MON[e["month"]]} {year}</b> · {html.escape(e["rating"])}<br><strong>{html.escape(e["title"])}</strong><br><small>{html.escape(e["note"])}</small></figcaption></figure>')
out = f'{d}/contact-sheet.html'
open(out, 'w', encoding='utf-8').write(f'''<!doctype html><meta charset="utf-8"><title>{html.escape(data["person"]["name"])} – Kontaktbogen</title>
<style>body{{font-family:system-ui;background:#111;color:#eee;margin:0;padding:20px}}h1{{font-weight:600}}
.grid{{display:grid;grid-template-columns:repeat(auto-fill,minmax(320px,1fr));gap:18px}}figure{{margin:0;background:#1c1c1c;border-radius:10px;overflow:hidden}}
.img{{aspect-ratio:4/3;background:#000;display:flex;align-items:center;justify-content:center}}img{{width:100%;height:100%;object-fit:contain}}
figcaption{{padding:10px 12px;font-size:13px;line-height:1.4}}small{{color:#aaa}}.missing{{color:#888}}</style>
<h1>{html.escape(data["person"]["name"])} – {len(cards)} Events</h1><div class="grid">{"".join(cards)}</div>''')
print(out)