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 :)



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


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.


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


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.


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


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.


Render SVG to a pmap at the requested scale.


Encoders and decoders for image formats supported by Imlib2.


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


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


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



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


True Type Font rendering.


Font registry


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


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


SDL display target, with input handling.


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


Long dead display target, not currently maintained.


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