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.

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.0

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.0
File Size Uploaded Provenance Actions
purepix-0.3.0.tar.gz 136.5 kB Without provenance Details for purepix-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 256.0 kB

Release files / purepix-0.3.0.tar.gz

Download URL purepix-0.3.0.tar.gz
Size 136.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f661fa665d7519b5058ac3abc137d845b679a0922358343dadeec800f06114cb
BLAKE2b-256 checksum
How to use checksums
095b59eb77d2bd7c7bee681d942390bce1f8d7c929088a863c696f3dc95038d9
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.0-py3-none-any.whl

Download URL purepix-0.3.0-py3-none-any.whl
Size 119.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
db081509eb7b558acbc2ed0f566b5f4345db3bb6af1bb270ac6f93896335bf65
BLAKE2b-256 checksum
How to use checksums
91ea1a114694dc3fc949f3343b7b2b085f1f911d4013971debbe391fe6af7727
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.0

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