Skip to main content

Pure-Python, zero-dependency image library: codecs (PNG/JPEG/GIF/BMP/...), processing, drawing, QR/barcodes, and generative art — all from scratch

Project description

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
  • Compression written from scratch: DEFLATE (dynamic Huffman) and GIF LZW

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
  • composite — blend modes, alpha compositing, linear/radial gradients
  • quantize — median-cut + Floyd–Steinberg dithering
  • morphology — erode/dilate/open/close, connected components
  • 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), flood fill, and text via a built-in bitmap font

Tools

  • qr — QR code generator (Reed–Solomon, masking, format info)
  • barcode — Code 128 and EAN-13
  • 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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

purepix-0.1.0.tar.gz (102.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

purepix-0.1.0-py3-none-any.whl (91.7 kB view details)

Uploaded Python 3

File details

Details for the file purepix-0.1.0.tar.gz.

File metadata

  • Download URL: purepix-0.1.0.tar.gz
  • Upload date:
  • Size: 102.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for purepix-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a5ac1fac8b5bcb3b2c1f5caec2ae5fb6a01da0436bac778659c10169f0f9bc26
MD5 c2c23537d335fb0f9fdcbf8d3d5d72b5
BLAKE2b-256 08b4d3da7263ad46df28aab9f88b4387332af7037664d4d329a987276bad3f88

See more details on using hashes here.

File details

Details for the file purepix-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: purepix-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 91.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.9

File hashes

Hashes for purepix-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d84cdf99bedff4c547831ed15c692c1970292bdecd2a5dfa70171cc2a37008ef
MD5 4ec74223b0a4bfe39817e8ad2a0424fc
BLAKE2b-256 6d1910bfd888033c07f9cb40f55e2d63d33b0db1b05fd92534eb946774c5e459

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page