#!/usr/bin/env python3 """Regenerates the JPEG fixtures used by tests/decode.rs. Run from the repository root: python3 tests/data/generate.py Each fixture is a solid colour so the test can assert exact sample values after decoding. Green is deliberate: it is the colour the ATEM keys on, and a wrong YUV matrix or range shows up here before it shows up on stage. """ from PIL import Image import pathlib OUT = pathlib.Path(__file__).parent W, H = 64, 32 GREEN = (0, 255, 0) # PIL subsampling codes: 0 = 4:4:4, 1 = 4:2:2, 2 = 4:2:0 for name, subs in [("green-444.jpg", 0), ("green-422.jpg", 1), ("green-420.jpg", 2)]: Image.new("RGB", (W, H), GREEN).save(OUT / name, "JPEG", quality=95, subsampling=subs) Image.new("L", (W, H), 128).save(OUT / "gray.jpg", "JPEG", quality=95) for p in sorted(OUT.glob("*.jpg")): print(f"{p.name}: {p.stat().st_size} bytes")