Pixel (package)

Pixel is a collection of packages for working with raster (pixel based) images, with a particular focus on quality and speed. It has accreted over the last 20 years or so and some parts of it are showing their age, but it is still in daily production use processing dozens of images a second.

Some of the packages listed below are flagged as "not currently maintained" - this framework has been around long enough to see a few libraries and systems it used pass away, the packages are still around and could be dusted off if the need ever arises though. There are also a few that I no longer use and so don't actively maintain, but they could be revived too if the need ever arose.

Documentation is sparse, but the sources are designed to be easy to read :)

Core

Pixel

The core pixel package (Pixel, pixel_core directory in the repo) contains the scaling, transformation, compositing operations, and defines the core types used by the pixel system (the Tcl types pmap and pmapf). It is designed to autovectorize with a competent C compiler and the right optimization flags (so it will use the best available SIMD extension available on the target hardware, build with "-O3 -march=native" if you're compiling on the target machine with gcc).

pmap

The older image type, that many of the APIs still use. It represents images using four 8-bit colour channels: red, green, blue and alpha (transparency), in sRGB colour space.

pmapf

The newer, linear colour space version of pmap: it represents images using four single precision floating point channels: red, green, blue and alpha (transparency), in linear colour space.

Image Encoders and Decoders

Pixel_jpeg

Encoders and decoders for JPEG format images, can load and save directly to and from files, or operate on bytearray values. Uses libjpeg-turbo, very fast.

Pixel_png

Encoder and decoder for PNG images, plus some PNG utility functions.

Pixel_webp

Encoder and decoder for WebP images, which are similar to JPEGs but higher quality at the same file size, and support a full alpha channel.

Pixel_svg_cairo

Render SVG to a pmap at the requested scale.

Pixel_imlib2

Encoders and decoders for image formats supported by Imlib2.

Pixel_heif

Encoder and decoder for HEIF images, a format based on the H.264 video codec. Questionable patent situation and very slow compared to WebP.

Pixel_tiff

File loader and saver for TIFF images, not currently maintained.

Pixel_xcf

Loader for Gimp's native .xcf format, providing access to the layers. Not currently maintained.

General

Pixel_fftw

Fast fourier transform for pmaps, can be used to estimate the natural scale of images that have been upscaled.

Pixel_ttf

True Type Font rendering.

Pixel_fonts

Font registry

Pixel_phash

Perceptual hashing of images - can be used to cluster similar images. Pairs of images with a small hamming distance are very likely the same image, but processed differently (colour manipulations, scaling, cropping, compressed differently, watermarked, etc).

Output Targets

Pixel_gl

A useful subset of the OpenGL api wrapped in a Tclish style. Supports shaders.

Pixel_sdl

SDL display target, with input handling.

Pixel_tkimage

Wrap a pmap in a Tk image to use it in a Tk application, not currently maintained.

Pixel_ptc

Long dead display target, not currently maintained.

Links

Hosted on github: https://github.com/cyanogilvie/pixel