Keep album full-screen after GIF and reduce motion-region flicker.
Unify STRETCH layout for all photos, decode GIF 1:1 with disposal restore, and ship a 160x120 sample GIF. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Generate 320x240 JPG/PNG/GIF samples into assets/photos (solid bg, no stripes)."""
|
||||
"""Generate test photos into assets/photos (solid bg; GIF is 160x120 for 1:1 decode)."""
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
@@ -9,6 +9,7 @@ from PIL import Image, ImageDraw, ImageFont
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
OUT = ROOT / "assets" / "photos"
|
||||
W, H = 320, 240
|
||||
GIF_W, GIF_H = 160, 120
|
||||
|
||||
|
||||
def font(size: int = 28) -> ImageFont.ImageFont:
|
||||
@@ -27,7 +28,6 @@ def font(size: int = 28) -> ImageFont.ImageFont:
|
||||
def card(bg, accent, title: str, subtitle: str, path: Path, fmt: str) -> None:
|
||||
im = Image.new("RGB", (W, H), bg)
|
||||
d = ImageDraw.Draw(im)
|
||||
# Solid panel only — no horizontal stripe decoration
|
||||
d.rounded_rectangle((20, 36, W - 20, H - 36), radius=12, fill=bg, outline=accent, width=3)
|
||||
d.text((36, 70), title, fill=(234, 240, 246), font=font(36))
|
||||
d.text((36, 130), subtitle, fill=(160, 175, 190), font=font(20))
|
||||
@@ -45,23 +45,25 @@ def main() -> None:
|
||||
card((28, 12, 18), (232, 93, 76), "02 JPG", "red sample", OUT / "02_red.jpg", "JPEG")
|
||||
card((8, 28, 20), (61, 220, 151), "03 PNG", "green sample", OUT / "03_green.png", "PNG")
|
||||
|
||||
# 160x120 GIF matches decode canvas → no downscale flicker on moving regions.
|
||||
frames = []
|
||||
for i in range(6):
|
||||
im = Image.new("RGB", (W, H), (10, 16, 22))
|
||||
for i in range(8):
|
||||
im = Image.new("RGB", (GIF_W, GIF_H), (10, 16, 22))
|
||||
d = ImageDraw.Draw(im)
|
||||
d.text((24, 24), "04 GIF", fill=(234, 240, 246), font=font(32))
|
||||
d.text((24, 70), "animated", fill=(160, 175, 190), font=font(18))
|
||||
x = 20 + i * 40
|
||||
d.rounded_rectangle((x, 120, x + 80, 180), radius=8, fill=(255, 200, 40))
|
||||
d.text((8, 8), "04 GIF", fill=(234, 240, 246), font=font(22))
|
||||
d.text((8, 36), "160x120", fill=(160, 175, 190), font=font(14))
|
||||
x = 4 + i * 14
|
||||
d.rounded_rectangle((x, 60, x + 40, 100), radius=6, fill=(255, 200, 40))
|
||||
frames.append(im)
|
||||
gif_path = OUT / "04_bounce.gif"
|
||||
frames[0].save(
|
||||
gif_path,
|
||||
save_all=True,
|
||||
append_images=frames[1:],
|
||||
duration=120,
|
||||
duration=80,
|
||||
loop=0,
|
||||
optimize=False,
|
||||
disposal=2, # restore to background — handled in firmware
|
||||
)
|
||||
print(f"wrote {gif_path} ({gif_path.stat().st_size} bytes)")
|
||||
print("DONE")
|
||||
|
||||
Reference in New Issue
Block a user