Skip to main content

purepix

A pure-Python, zero-dependency image library — codecs, processing, drawing, and a pile of generative art, all implemented from scratch on top of the standard library. No NumPy, no Pillow, no C extensions.

import purepix
img = purepix.open("photo.jpg")          # auto-detected by magic bytes
small = img.resize((320, 240), purepix.BILINEAR)
purepix.save(small.filter(purepix.filters.SHARPEN), "out.png")

Install

pip install purepix

Requires Python 3.10+. Zero runtime dependencies.

0.3.1 fixes

16-bit PNG transparent-color keys now preserve their full precision. Both purepix.save(img, path, **options) and img.save(path, **options) accept pathlib paths and forward PNG transparency and interlace options. Interlaced PNG writing remains limited to 8-bit images; unsupported options raise errors.

What's inside

Image formats (read/write unless noted)

  • BMP, PNG (1/2/4/8/16-bit, Adam7 interlace, tRNS, lossless 16-bit), GIF (incl. animated), PNM (PPM/PGM), TGA (RLE), ICO, farbfeld, WBMP, PCX, XPM
  • JPEG — baseline and progressive decode + baseline encode
  • QOI — lossless, full round-trip
  • TIFF — LE/BE, none / PackBits / LZW / DEFLATE, multi-strip, multi-page
  • APNG — animated PNG read/write (offset, blend & dispose ops)
  • Compression written from scratch: DEFLATE (dynamic Huffman, greedy + lazy matching), GIF LZW, TIFF LZW, PackBits

Core image ops (Image)

  • 8-bit and 16-bit depth, mode conversion, crop, paste, split/merge channels
  • resize (nearest / bilinear), flip, rotate (90° and arbitrary angle), affine
  • point LUTs, convolution filter

Processing

  • filters — blur / gaussian / sharpen / unsharp / median / edge / sobel / emboss, brightness / contrast / gamma / invert / threshold / posterize / solarize, histogram / equalize / autocontrast, ordered dithering
  • color — RGB↔HSV, hue/saturation/value, sepia; CIELAB / LCh, ΔE (CIE76 & CIEDE2000), tone curves, vibrance, color temperature, gray-world white balance, levels
  • composite — blend modes, alpha compositing, linear/radial gradients
  • quantize — median-cut + Floyd–Steinberg dithering
  • morphology — erode/dilate/open/close, connected components
  • features — Canny edges, Hough lines/circles, Harris corners, contour tracing
  • effects — pixelate, vignette, motion blur, cartoon, glitch, oil paint
  • seam — content-aware resize (seam carving)
  • compare — aHash/dHash/pHash, PSNR, SSIM

Drawing (Draw)

  • point, line, wide/anti-aliased line, rectangle, rounded rectangle, ellipse, arc, polygon (scanline fill), Bézier & Catmull-Rom curves, flood fill, and text via a built-in bitmap font

Tools

  • qr — QR code generator and decoder (Reed–Solomon encode/decode, masking, format info)
  • barcode — Code 128 and EAN-13, encode and decode
  • stego — LSB steganography
  • exif — JPEG EXIF / PNG text metadata, auto-orient
  • dft — 2-D DFT: spectrum + low/high-pass filtering
  • ascii_art — render images to ASCII / ANSI

Generative art & simulation

  • fractal (Mandelbrot/Julia), noise (Perlin/fBm, clouds, marble), lsystem, reaction (Gray-Scott), automata (Life + elementary CA), maze, wfc, raytrace, plasma/fire, dla, voronoi/stippling, flowfield, sortviz, astar

Command line

python -m purepix info photo.png
python -m purepix convert in.png out.jpg --quality 90
python -m purepix resize in.png out.png --size 320x240
python -m purepix qr "https://example.com" qr.png
python -m purepix hash photo.png --type phash

Example

import purepix
from purepix import Draw, fractal, qr

# generate a fractal
fractal.mandelbrot((400, 300), max_iter=150).save("mandelbrot.png")

# draw with the built-in font
img = purepix.Image.new("RGB", (200, 60), (20, 20, 30))
Draw(img).text((10, 20), "PUREPIX", (0, 255, 180), scale=3)
img.save("banner.png")

# make a QR code
qr.encode("hello world", ec="M").save("qr.png")

License

MIT © Equinox

Metadata

Release files for purepix 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for purepix 0.3.1
File Size Uploaded Provenance Actions
purepix-0.3.1.tar.gz 141.7 kB Without provenance Details for purepix-0.3.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for purepix 0.3.1
File Interpreter ABI Platform Actions
purepix-0.3.1-py3-none-any.whl Python 3 none any Details for purepix-0.3.1-py3-none-any.whl

Total release size: 261.5 kB

Release files / purepix-0.3.1.tar.gz

Download URL purepix-0.3.1.tar.gz
Size 141.7 kB
Tags Source
SHA-256 checksum
How to use checksums
399f2faea4d8361cddb18b096979c3b5f2bbddfbea655942a564eff5c5a5f0ca
BLAKE2b-256 checksum
How to use checksums
51d3e63d6e15e75270903626247438b670b30c8b5de65617fe0e91b0760e873d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.9

Release files / purepix-0.3.1-py3-none-any.whl

Download URL purepix-0.3.1-py3-none-any.whl
Size 119.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e5232317d237d96f318e6bd3bfa53a84265785a30c3eb7064805da19d16a8ff9
BLAKE2b-256 checksum
How to use checksums
85d33a9769b2bc9ae62f4dde7c3d2b801aca2480f2da9b66408d11c184cc2c9f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.9

Security for purepix 0.3.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page