poka.sh

Docs

XPM

Generated by scripts/gen-format-pages.py from docs/data/format-metadata/, FILE_FORMATS.csv and docs/formats-master.csv. Do not edit by hand: change the source, then run the script.

XPM Image Preview.

At a glance

Original creator Daniel Dardailler and Colas Nahaboo of Bull Research, later enhanced by Arnaud Le Hors
First published 1989
Purpose X PixMap: colour images for the X Window System written as C source, a string per palette entry and per row of pixels.
Extensions .xpm
Poka parser poka-xpm
Viewer poka-image-with-meta-viewer
Depth tier Parser with a shared viewer (see Depth tiers)
Breadth tier B2 Broad (see Breadth tiers)

How much Poka reads

B2 Broad. The common content of the current and the common older versions is decoded. Some named features or versions are not, and are listed.

Confidence: medium (the reviewer read the code). Basis: Reviewed 2026-10-16: parsers/poka-xpm/src/lib.rs and tests/samples.rs. Both corpus files (tdf111925-1.xpm with 203 colours at 2 characters per pixel, and TypeDetectionExample.xpm) use hex colours only, so named colours are not exercised by the corpus. Covers XPM3 (the C-wrapped layout).

What Poka does not read

  • named colours: the built-in table has about 40 names, and any other X11 name is drawn as mid-grey; the table also uses CSS values (for example 'green' as 0,128,0, where X11 has 0,255,0)
  • HSV colours (%H,S,V) and nine-digit hex colours are not parsed
  • symbolic names (s) are ignored
  • XPM1 and XPM2 layouts
  • XPMEXT extension data is flagged but not read
  • the m, g and g4 visuals are used only as a fallback when there is no c visual

Background

Wikipedia dates the first XPM to 1989, XPM2 (no C wrapper) to 1990 and XPM3, the current and last version, to 1991. Poka extracts the quoted strings, builds the palette from the colour visual (falling back to the grey and mono visuals) and draws the pixel rows into a PNG. The declared size is checked against the memory budget before the buffer is allocated.

Versions

Version Identifier Poka Note
XPM3 /* XPM */ Partly read The C-wrapped layout parsers/poka-xpm/src/lib.rs describes. The colour-name table has about 40 entries, not the X11 list, and some use CSS values; any other name is drawn mid-grey.

Libraries

Libraries Poka uses or has assessed for this format, with the status, licence and language the registry records.

  • image (used; MIT OR Apache-2.0; Rust)
  • png (used; MIT OR Apache-2.0; Rust)
  • image-extras (candidate; Apache-2.0 OR MIT; Rust; https://github.com/image-rs/image-extras) — Extra decoders for the image crate with an xpm feature; README warns decoders may panic on malformed input. Dual licence inferred from LICENSE-APACHE and LICENSE-MIT files.

Sources