An open-source CGM (Computer Graphics Metafile) parser and CGM→SVG converter.
CGM is the vector format that aerospace, defence, and automotive technical publications have standardised on for three decades — it is what S1000D and ATA iSpec 2200 illustrations are authored in. The open-source tooling for it has not kept up: RALCGM is unmaintained, and ImageMagick and Inkscape have effectively no usable CGM support.
OpenCGM is a modern, actively developed implementation: a complete ISO/IEC 8632 parser, a Skia-backed renderer, and an SVG emitter with profile support for WebCGM 2.1 and S1000D.
- Parses CGM binary and clear-text encodings per ISO/IEC 8632-3:1999 and ISO/IEC 8632-4:1999
- Converts CGM to SVG with WebCGM 2.1 and S1000D output profiles
- Preserves application structure (APS) — layers, names, screentips, link URIs, and region hotspots survive the conversion
- Handles the parts that usually break: NURBS approximation, cell arrays, tile rasters (JPEG / PNG / bitmap / CCITT G4), pattern and hatch geometry, and font substitution with ACI font normalisation
- Ships a C API for embedding, a CLI, and a validation tool
- Round-trips CGM → CGM as well as converting
Prebuilt binaries for Windows and Linux are on the releases page. You only need to build from source to change the code or to target another platform.
| Archive | Runs on |
|---|---|
opencgm-windows-x64.zip |
64-bit Windows 10 or later. Nothing else to install. |
opencgm-linux-x64.tar.gz |
64-bit Linux with glibc 2.35 or later (Ubuntu 22.04+, Debian 12+). |
Unpack the archive and run the converter from its bin folder:
# Windows
.\opencgm-windows-x64\bin\opencgm_cli.exe input.cgm output.svg# Linux
tar xzf opencgm-linux-x64.tar.gz
./opencgm-linux-x64/bin/opencgm_cli input.cgm output.svgEach archive also contains include/ and lib/ for embedding the library.
To check a download against the published checksums:
sha256sum --check --ignore-missing SHA256SUMS # LinuxGet-FileHash opencgm-windows-x64.zip -Algorithm SHA256 # Windows: compare with SHA256SUMSRequires CMake 3.15+, a C++17 compiler, and optionally
Skia for the native renderer (consumed via vcpkg; see
vcpkg.json, and configure with -DENABLE_SKIA_RENDERER=ON). A plain build
needs no network access.
cmake -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config ReleaseThis produces opencgm_cli, cgm_validate, and the opencgm shared
library. Single-configuration generators (Make, Ninja) put them in
build/bin. Multi-configuration generators (Visual Studio, Xcode) use a
subdirectory per configuration, such as build/bin/Release. Without
--config Release you get an unoptimised Debug build.
On Windows, clone to a short path such as C:\src\opencgm. MSBuild's
file-tracking logs nest deeply under build/, and a long checkout path can
exceed the 260-character limit, which surfaces as CMake reporting
No CMAKE_CXX_COMPILER could be found.
opencgm_cli --profile s1000d input.cgm output.svgCommon options:
--profile <s1000d|s1000d-legacy|webcgm|compat>— output profile (s1000dis the default;s1000d-legacytargets pre-Issue 6 IETP viewers;compatrelaxes WebCGM rules for metafiles that use ISO 8632 segments)--preset <name>— apply a built-in preset from config/profile-presets.json:s1000d,s1000dlegacy,ata,webcgm,cals,pip,cgmplus. Individual flags override preset values.--font-map <file>— JSON font map describing CGM font substitutions and optional embedded WOFF2 resources--text-as-path/--text-as-path-threshold <value>— outline text for pixel-exact verification--validate-geometry— enforce viewBox/viewcontext consistency; tune with--geometry-tolerance <value>(default: 0.01 user units)--optimize— smaller output that renders the same: primitives sharing a style are grouped under one<g>, coordinates are rounded to 1/10000 of the picture, and comments and unused definitions are dropped. Large line illustrations typically halve. Off by default because the SVG's structure changes, which matters if your pipeline post-processes it. Add--minifyto also remove whitespace between elements.--fit-to-content/--no-fit-to-content— whether to crop the viewBox to the drawing (plus a 2% margin) instead of the whole VDC extent, so a drawing that sits in part of a sheet fills the browser window. On by default in every profile exceptwebcgm, whose initial view is the full picture;--fit-to-contentturns it on there too. Line widths, markers and text are measured; elements drawn in the background colour, such as invisible sheet frames, are ignored. When the picture contains something whose extent can't be measured (tiles, symbols, segment copies), the full picture is kept, and if you asked for the fit the conversion report says why.--geometry-log/--raster-log— emit diagnostics to stderr
opencgm_cli --help lists every flag, including watch-folder mode
(--watch <dir> --output-dir <dir>). opencgm_cli --version prints the
version.
cgm_validate input.cgm checks a metafile against a profile (WebCGM 2.1,
ATA GREXCHANGE, S1000D, or ISO 8632; auto-detected by default) without
converting it. Add --json for machine-readable output, or use --dump to
list every element with its ISO 8632 class and ID.
Convert through the stable C API in include/opencgm/c_api.h, which is also
the surface for binding from other languages:
#include <opencgm/c_api.h>
opencgm_ctx_t* ctx = opencgm_create();
opencgm_set_profile(ctx, "s1000d");
if (opencgm_convert_cgm_to_svg(ctx, "input.cgm", "output.svg") != OPENCGM_OK) {
fprintf(stderr, "%s\n", opencgm_last_error());
}
opencgm_destroy(ctx);Or work with the parsed metafile directly in C++:
#include <opencgm/cgm_file.h>
opencgm::BinaryCGMFile cgmFile("input.cgm");
for (const auto& command : cgmFile.commands()) {
// inspect or transform, e.g. command->toString()
}
cgmFile.writeFile("output.cgm");| Path | Contents |
|---|---|
src/core/, src/classes/ |
CGM file handling and data structures |
src/commands/ |
CGM command implementations |
src/import/, src/export/ |
Binary and clear-text parsing and writing |
src/svg/ |
SVG emission and profile handling |
src/skia/ |
Skia renderer |
src/nurbs/, src/xcf/ |
NURBS approximation, XCF support |
src/validation/ |
Profile and geometry validation |
include/opencgm/ |
Public headers and C API |
tests/ |
Unit tests and corpus-driven conversion tests |
Tests are off by default because enabling them downloads GoogleTest, which needs git and network access:
cmake -B build -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=ON
cmake --build build --config Release
ctest --test-dir build -C ReleaseThat runs green on a fresh clone. Sample corpora are not vendored — the WebCGM 2.1 Conformance Test Suite and the S1000D Bike Data Set are third-party data under their own terms — so tests needing a corpus skip until you fetch one:
python scripts/fetch-testdata.py
export OPENCGM_SAMPLES_DIR=$PWD/testdata # bash
$env:OPENCGM_SAMPLES_DIR = "$PWD\testdata" # PowerShellThe WebCGM suite downloads automatically from OASIS with a pinned checksum and activates 31 further tests. The S1000D Bike Data Set is distributed through the S1000D users' portal and must be installed by hand; the script prints instructions. Two golden fixtures also use ATA iSpec 2200 GREXCHANGE test metafiles, which are not publicly redistributable and stay skipped unless you have them (the script says where to put them).
Every file in the WebCGM 2.1 Conformance Test Suite (353 CGMs) converts successfully under all three output profiles, producing well-formed SVG:
| Profile | Converted | Failures |
|---|---|---|
webcgm |
353/353 (100%) | 0 |
s1000d |
353/353 (100%) | 0 |
compat |
353/353 (100%) | 0 |
Full results, including how much the profiles actually diverge from one
another, are in docs/corpus-report.md. The report is
generated by scripts/corpus-report.py and is reproducible from a clean
checkout.
This measures conversion coverage and SVG well-formedness, not visual fidelity, and is not a WebCGM conformance certification.
The WebCGM static test suite ships its methodology in machine-readable form:
static10/webCGMsuite.xml lists the official operator checkpoints for each of
its 232 rendering test cases. scripts/conformance.py runs them:
| Checkpoints | |
|---|---|
| total | 912 |
| decided mechanically | 438 (48%) |
| passed | 438 |
| failed | 0 |
| require an operator | 474 (52%) |
Full results by CGM category are in
docs/conformance-report.md. Checkpoints that
describe what a person should see are written to an operator worksheet
(--worksheet) pairing each reference image with this converter's rendering.
This is not a conformance certification, and OpenCGM does not claim WebCGM
conformance: that is defined for viewers, and the suite's 20tests,
21tests and dynamic10 modules almost entirely exercise a viewer's DOM and
XCF APIs and link navigation, which a converter has no part in. The static10
module is the part that tests rendering, and it is what is measured.
scripts/visual-compare.py additionally rasterises converted output and ranks
all 312 reference-paired cases, static10 included, by divergence from the
reference images (docs/visual-comparison.md) as a
regression screen; it has already surfaced real gaps. Reproduce it with any
rasteriser, for example
resvg (cargo install resvg):
python scripts/visual-compare.py --cli build/bin/opencgm_cli \
--corpus testdata/webcgm21-ts --out docs/visual-comparison.md \
--rasterizer "resvg --width {w} --height {h} {svg} {png}"See CONTRIBUTING.md. The most useful contributions are usually narrow: a CGM file that renders wrong, plus a test pinning the correct behaviour.
Licensed under the Apache License 2.0.
OpenCGM is a C++ port of the codessentials.CGM C# library by Toni Wenzel, used under the MIT License. See NOTICE and THIRD-PARTY-NOTICES.md for full attribution.
Reforge, a commercial desktop application built on this engine — batch conversion, folder monitoring, a validation UI, and hotspot export — is available separately. OpenCGM itself is and remains Apache-2.0.