chore: vollständiger Workspace-Snapshot 03.07.2026
- publish_gatekeeper.py (neues Gatekeeper-System) - 4 Premium-Artikel: Veggie Match, Berlin 1960, Wild Tiled West, Scream Park - Alle kumulierten Artikel, Scripts, Medien und Caches
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
#!/home/hermes/venv/bin/python3
|
||||
"""Create deal graphic for Lacrimosa using the SALE burst template"""
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
import numpy as np, os
|
||||
|
||||
# Template laden
|
||||
bg = Image.open('/home/hermes/workspace/media/templates/sale_burst_template.jpg').convert('RGB')
|
||||
W, H = bg.size
|
||||
|
||||
# Cover laden — ALLE fast-weißen Pixel transparent machen
|
||||
cover = Image.open('/tmp/cover_Lacrimosa.jpg').convert('RGBA')
|
||||
arr = np.array(cover)
|
||||
is_white = np.all(arr[:,:,:3] > 245, axis=2)
|
||||
arr[is_white, 3] = 0
|
||||
cover = Image.fromarray(arr, 'RGBA')
|
||||
|
||||
# Auf Content croppen
|
||||
non_transparent = arr[:,:,3] > 0
|
||||
rows = np.any(non_transparent, axis=1)
|
||||
cols = np.any(non_transparent, axis=0)
|
||||
r_idx, c_idx = np.where(rows)[0], np.where(cols)[0]
|
||||
cover = cover.crop((c_idx[0], r_idx[0], c_idx[-1]+1, r_idx[-1]+1))
|
||||
|
||||
# Cover LEICHT KIPPEN (-7°) für Dynamik
|
||||
cover = cover.rotate(-7, expand=True, resample=Image.BICUBIC, fillcolor=(0,0,0,0))
|
||||
|
||||
# Auf Zielgröße skalieren (~40% Breite)
|
||||
target_w = int(W * 0.40)
|
||||
cw = target_w
|
||||
ch = int(cw / (cover.width / cover.height))
|
||||
if ch > H * 0.82:
|
||||
ch = int(H * 0.82)
|
||||
cw = int(ch * (cover.width / cover.height))
|
||||
cover = cover.resize((cw, ch), Image.LANCZOS)
|
||||
|
||||
# Auf Template pasten
|
||||
bg_rgba = bg.convert('RGBA')
|
||||
bg_rgba.paste(cover, (int(W*0.05), (H-ch)//2-16), cover)
|
||||
bg = bg_rgba.convert('RGB')
|
||||
|
||||
# Footer
|
||||
draw = ImageDraw.Draw(bg)
|
||||
footer = 'Brettspiel-News.de · (C) liegt beim jeweiligen Rechteinhaber'
|
||||
font = ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf', 11)
|
||||
bbox = draw.textbbox((0,0), footer, font=font)
|
||||
tw = bbox[2] - bbox[0]
|
||||
draw.text(((W-tw)//2, H-22), footer, fill='white', font=font)
|
||||
|
||||
# Speichern
|
||||
bg.save('/tmp/deal_Lacrimosa.jpg', 'JPEG', quality=92)
|
||||
print('Grafik: /tmp/deal_Lacrimosa.jpg gespeichert')
|
||||
print(f'Size: {os.path.getsize("/tmp/deal_Lacrimosa.jpg")} bytes')
|
||||
Reference in New Issue
Block a user