CGM
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.
Computer Graphics Metafile.
At a glance
| Original creator | ANSI and ISO/IEC JTC 1 |
| First published | 1986 |
| Purpose | The Computer Graphics Metafile: an application-independent ISO standard for 2D vector graphics, raster cells and text. |
| Extensions | .cgm |
| Poka parser | poka-cgm |
| Viewer | poka-vector-viewer |
| Depth tier | Parser with a shared viewer (see Depth tiers) |
| Breadth tier | B3 Core (see Breadth tiers) |
How much Poka reads
B3 Core. Only the main content type or types are decoded (for example geometry but not materials, layers or annotations, or only one version family). The list of gaps is substantial.
Confidence: high (the reviewer read the code and a test that proves the claim). Basis: Reviewed 2026-10-19: parsers/poka-cgm/src/lib.rs (clear text), binary.rs, character.rs, arc.rs, raster.rs, dcc.rs, unit tests and tests/samples.rs over 11 corpus files (clear text, binary and character encodings, including the generated poka_cgm_arcs_cells_* triplet checked across encodings). Covers geometry and colour in all three encodings: lines, polygons, rectangles, circles, arcs, ellipses, text with height and alignment, cell arrays, colour tables, VDC extent. The viewer is poka-vector-viewer.
What Poka does not read
- line width, line type (dashes), edge width and edge type are consumed but never drawn
- hatch and pattern fills (PATTERN TABLE is consumed, not drawn); only filled or hollow
- marker size and marker type: a marker is drawn as a dot whatever marker size or type the file set
- text font, character orientation, text path, spacing, expansion and APPEND TEXT in binary
- clipping rectangle, scaling mode, background colour and metric
- multiple pictures in one metafile are merged into one drawing; no picture structure
- bundled attribute tables and aspect source flags
- generalised drawing primitives in binary and clear text
- WebCGM application structures and hyperlinks
- incremental point lists in the character encoding are covered only by hand-built unit tests (no real file)
Background
The Library of Congress says CGM was first published as ANSI X3.122-1986, then as ISO 8632-1:1987, drawing on the Graphical Kernel System. ISO/IEC 8632:1992 defined three versions of increasing capability, and the current standard is ISO/IEC 8632-1:1999. WebCGM is a W3C profile of it. The standard defines three encodings and Poka decodes all three: clear text, binary and character. Text elements keep their label, height and alignment; arcs and ellipses are flattened to polylines; cell arrays become images. The result is drawn by the vector viewer. Line width and type, edge width and type, and pattern fills are not drawn.
Versions
| Version | Identifier | Poka | Note |
|---|---|---|---|
| Binary encoding (ISO/IEC 8632-3) | Partly read | Polymarker (element 4,3) is one point per position and polygon set (4,8) reads its per-point edge-out flags, so its contours split into rings; the clear-text reader handles POLYMARKER and POLYGONSET too (parsers/poka-cgm/src/binary.rs, src/lib.rs). | |
| Character encoding (ISO/IEC 8632-2) | Read | ||
| Clear text encoding (ISO/IEC 8632-4) | BEGMF |
Read | POLYMARKER (one point per position) and POLYGONSET (each point followed by its edge-out flag, 2 or 3 closing a ring) are read, alongside the other primitives (parsers/poka-cgm/src/lib.rs). |
Libraries
Libraries Poka uses or has assessed for this format, with the status, licence and language the registry records.
- png (used; MIT OR Apache-2.0; Rust)
- roxmltree (used; MIT OR Apache-2.0; Rust)
- zip (used; MIT; Rust)
- CGM (codessentials) (candidate; MIT; C#; https://github.com/twenzel/CGM)
- LibreOffice core icgm import filter (candidate; MPL-2.0; C++; https://github.com/LibreOffice/core/tree/master/filter/source/graphicfilter/icgm) — MPL-2.0 is file-level copyleft; wasm use needs a deny.toml exception
- CgmInfo (reference; GPL-3.0; C#; https://github.com/BhaaLseN/CgmInfo) — reference only, not usable in wasm
- WebCGM 2.1 (W3C profile of ISO/IEC 8632) (candidate; public spec; spec; https://www.w3.org/TR/webcgm21/)
Sources
- https://www.loc.gov/preservation/digital/formats/fdd/fdd000521.shtml
- parsers/poka-cgm/src/lib.rs