16 lines
802 B
Python
16 lines
802 B
Python
"""Render the committed SVGs only in remote CI and compare their actual pixels."""
|
|
from pathlib import Path
|
|
import io, json
|
|
from PIL import Image
|
|
import resvg_py
|
|
|
|
root = Path(__file__).resolve().parents[1]
|
|
manifest = json.loads((root / 'assets/manifest.json').read_text())
|
|
for variant in manifest['variants']:
|
|
svg = (root / f'assets/svg/{variant}.svg').read_text()
|
|
for size in manifest['png_sizes']:
|
|
actual = Image.open(io.BytesIO(resvg_py.svg_to_bytes(svg_string=svg, width=size, height=size, shape_rendering='geometric_precision'))).convert('RGBA')
|
|
stored = Image.open(root / f'assets/png/{variant}/endoleap-{size}.png').convert('RGBA')
|
|
assert actual.tobytes() == stored.tobytes(), (variant, size)
|
|
print('72 PNG assets exactly match their committed fixed-path SVGs.')
|