lib/image.py)
Import and export PNG/JPEG (and other Pillow formats), then apply
color and geometry edits. Every edit
returns a new image; the source is
never mutated. Load with
use image;
(extensionless:
reqFileExtension = False).
Needs Pillow + numpy:
pip install 'someProgrammingLanguage[play]'
or Pillow and numpy on their own. Check with
image.depsOk()
(1 /
0). Paths are cwd-relative (no
.., no absolute paths). Imports cap at
4096px on the long side.
use image;
img.setVar(image.import("photo.png"));
warm.setVar(image.hue(img, 20));
image.export(warm, "edited.png");
No photo on disk? image.demo() builds a
colorful test image.
Methods work too: img.export("out.png"),
img.hue(20),
img.width().
hue (degrees), saturate (1 = original), brightness, contrast (1 = original), exposure (EV), temperature, tint, gamma, shadows, highlights, vignetteinvert, grayscale, sepia, blur(radius), sharpen(amount)flipH, flipV, rotate(degrees) (positive = clockwise), crop(x, y, w, h), resize(w, h)pixelate(size), posterize(levels), threshold(t)copy, width, height, create(w, h [, r, g, b, a]) (RGBA 0–1)
Play ships a slider editor (hue, saturation, brightness, contrast, exposure,
white-balance, gamma, shadows/highlights, vignette, blur/sharpen, plus invert /
gray / sepia / flip / rotate). Hold C to
compare with the original. Export writes
edited.png in the working directory.
use play;
use image;
win <- play.window(1280, 800, "SPL Image Editor");
ed <- play.imageEditor(win);
#comment: or: ed <- play.imageEditor(win, image.import("photo.png"));
Full loop:
examples/play/image_editor.spl.
Code-only pipeline:
examples/image_edit/image_edit.spl.
Implementation:
lib/image.py +
someProgrammingLanguage/spl_image.py
+ spl_play/image_editor.py