Skip to content

loomwork v0.4.0

Choose a tag to compare

@donkamonka17-spec donkamonka17-spec released this 05 Dec 13:50

loomwork v0.4.0 adds --palette-from IMAGE: use up to 5 dominant colours of a picture as the palette.

  • Colours are found by median cut on the image shrunk to fit 128 by 128 pixels, and sorted dark to light. They are printed as palette: #rrggbb,..., so you can reuse them with --palette. For photographs the colours are approximate and can differ between Pillow versions. They are exact only for images of up to 5 flat colours that are no larger than 128 pixels on a side; larger images are shrunk first, and blending at colour edges can add or shift a colour.
  • The alpha channel is dropped (transparent pixels count with the colour stored for them), and an animated image uses its first frame. An image with fewer than 2 distinct colours, an unreadable file, or using --palette together with --palette-from is refused with exit code 2 and writes nothing.
  • python3 -I tools/palettecheck.py checks the option on flat-colour images made on the spot, and CI runs it. Output without --palette-from is byte-identical to v0.3.0 (checked by cmp on PNG, SVG, preview and sheet output, and selfcheck).

CI (Python 3.12, Pillow 10.4.0, 11.3.0 and 13.0.0) passed selfcheck and palettecheck on the release commit; the job logs were read.

Known limits: only those Pillow versions were tested; no real-photo palette is pinned by a test; nobody outside has used it.