forked from mtusi2026/mtusi2026lab5
18 lines
628 B
Python
18 lines
628 B
Python
"""Regenerate synthetic JPEG fixtures (needs Pillow; run once in a throwaway container):
|
|
|
|
docker run --rm -v "$PWD/student-tests/fixtures:/out" python:3.12.8-slim-bookworm \
|
|
sh -c "pip install -q pillow==11.0.0 && python /out/make_jpeg_fixtures.py"
|
|
"""
|
|
|
|
from PIL import Image
|
|
|
|
im = Image.new("RGB", (320, 200))
|
|
px = im.load()
|
|
for y in range(200):
|
|
for x in range(320):
|
|
px[x, y] = (x * 255 // 319, y * 255 // 199, (x + y) % 256)
|
|
im.save("/out/sample.jpg", "JPEG", quality=85)
|
|
im.save("/out/progressive.jpg", "JPEG", quality=80, progressive=True)
|
|
im.convert("L").save("/out/gray.jpg", "JPEG", quality=80)
|
|
print("ok")
|