"""Render every Mode x Palette x Dither variation of an image, for the GUI's "Explore variations" contact sheet. Kept import-light (no Qt) so it can run in ProcessPoolExecutor worker processes. """ from __future__ import annotations from . import imageprep from .convert import MODES, render_preview, convert_image PALETTES = ["colodore", "pepto"] DITHERS = ["bayer", "floyd", "atkinson", "none"] # (mode, palette, dither) for every concrete mode (auto is excluded on purpose). COMBOS = [(m, p, d) for m in MODES for p in PALETTES for d in DITHERS] def render_variation(args): """Worker entry point. ``args`` = (path, mode, palette, dither, prep_kwargs). Returns (mode, palette, dither, error, rgb) where rgb is the displayed- resolution (320x200) preview as a uint8 HxWx3 array. """ path, mode, palette, dither, prep_kwargs = args prep = imageprep.PrepOptions(**prep_kwargs) conv = convert_image(path, mode=mode, palette_name=palette, dither_mode=dither, intensive=False, prep_opt=prep) rgb = render_preview(conv, palette, scale=1) return (mode, palette, dither, conv.error, rgb)