Community codec · 0.3.0 preview
Pack it. Restore it. Compare it.
Start with apertures.csv in the download. This small file grows when packed. Restore it and compare the two files byte for byte. The same commands work on a local copy of your own file with Python 3.9 or later.
Inside the download · apertures.csv
id,B00,B01,B10,B11,d,bx,by
open,1,0,0,1,0,0,0
- Original
- 99 B
- Packed
- 128 B
- Restored
- 99 B
ZIP · 212,682 bytes · MIT-licensed code
SHA-256: 9705349040b97b0bbc6becd4c72455a07e7679d523a3048ebbdb3c7c0f5239a8
Lossless file test
Restore an ordinary file.
Unzip the kit and open a terminal in its extracted folder. These commands pack the included example, inspect the chosen method and restore the original bytes. Use new output filenames. On macOS or Linux, cmp exits silently when the files match.
python3 cn-preview.pyz pack community_codec/examples/apertures.csv trial.cn
python3 cn-preview.pyz inspect trial.cn
python3 cn-preview.pyz unpack trial.cn restored.csv
cmp community_codec/examples/apertures.csv restored.csvThe 99-byte sample produces a 128-byte frame. That is expected: the example checks recovery, and a header costs bytes. Then substitute your own input. The preview accepts a single file up to 64 MiB. Eligible STEP text and fixed-width solar records up to 8 MiB can use specialized encodings. For eligible STEP files, the encoder tries grouping references and the original text of coordinate values before compression. The default uses Python’s built-in tools. Install the Brotli executable and add --with-brotli to try another encoding. To open a file packed with Brotli, the recipient needs Brotli too. The reader also opens files made by previews 0.1 and 0.2.
Aperture calculation
Ask the geometry a question.
Simulations can trade a bounded amount of numerical precision for a smaller record. This example builds a GX01 sidecar, verifies its transmission error against the source geometry, and queries the second aperture at horizontal slope 0.5.
python3 cn-preview.pyz geometry-pack community_codec/examples/apertures.csv example.gx01
python3 cn-preview.pyz geometry-verify community_codec/examples/apertures.csv example.gx01
python3 cn-preview.pyz geometry-query example.gx01 1 0.5 0The expected transmission is 0.75. The certificate bounds the normalized transmission error to 0.010 for the represented ideal geometry. Keep the original geometry and its coordinate frame.
Version 0.3 · STEP files
What changed for CAD?
Preview 0.3 adds ways to group recurring numbers in STEP text. The encoder compares its choices by complete packed size. The reader restores the original spelling, including trailing zeros.
On four further STEP files, preview 0.2 used 452,008 packed bytes and 0.3 used 444,905 with optional Brotli enabled in both. That saved 7,103 bytes (1.57%). Using the built-in encoders alone saved 292 bytes. Each file restored byte for byte.
Replication
Make an independent change.
Start with preview/preview_cli.py in the kit. The MIT license permits copying, modification and redistribution with its notice. The guide gives the build command, format notes and tests. Try a new exporter, report a slow decode, or compare a stronger baseline on identical files.
python3 preview/test_preview.py
python3 preview/build_preview.py