# ImageOps fixtures (tools/fixtures.py): Pillow references for ops/ImageOps. # tests/gen/imageops.luau { rgb = { w, h, px }, rgba = {...}, rgba2 = {...}, gray = L bytes of rgb, # resize = { { filter, mode, w, h, px } }, rotate = { { angle, expand, w, h, px } }, # composite = bytes } # rgb / rgba: smooth gradients + noise + shapes (Pillow drawing), deterministic. import struct CODE = r''' import random, struct, sys from PIL import Image, ImageDraw rng = random.Random(11) def src(w, h, mode): im = Image.new("RGBA", (w, h)) px = im.load() for y in range(h): for x in range(w): px[x, y] = ((x * 255) // (w - 1), (y * 255) // (h - 1), (x * y) % 256, 255 if mode == "RGB" else (x * 7 + y * 3) % 256) d = ImageDraw.Draw(im) for _ in range(5): x0, y0 = rng.randrange(w), rng.randrange(h) d.ellipse([x0, y0, x0 + rng.randrange(4, 20), y0 + rng.randrange(4, 20)], fill=(rng.randrange(256), rng.randrange(256), rng.randrange(256), 255 if mode == "RGB" else rng.randrange(256))) return im.convert(mode) out = [] def emit(tag, *parts): data = b"".join(parts) out.append(struct.pack("<16sI", tag.encode().ljust(16), len(data)) + data) rgb = src(61, 47, "RGB"); rgba = src(61, 47, "RGBA"); rgba2 = src(61, 47, "RGBA") hdr = lambda im: struct.pack("