Skip to main content

chuda

A CPU and CUDA high-quality truecolour ANSI renderer for image-training pipelines. It implements the expensive part of Chafa's effort-9 symbol mode: exhaustive foreground/background fitting and error scoring over the narrow symbol atlas. PNG decode, high-quality resize and stateful ANSI emission stay in Rust; independent cell/symbol evaluation runs on CUDA.

RGBA images are optimized jointly for either a detailed opaque foreground and background cell or a composable foreground-only cell. Alpha-mask agreement is part of symbol scoring, so antialiased sprite edges do not require two renders and a cell-level merge pass. --transparent-threshold controls the bias toward opaque interior detail and defaults to 0.10.

The atlas is generated from the vendored Chafa reference source and checked into the Rust binary. Chafa is not a build-time or runtime dependency.

Requirements

  • Rust 1.85 or newer
  • CUDA Toolkit and an NVIDIA driver only when building or selecting the optional CUDA backend

Build and run

cargo build --release
cargo run --release -- --size 80 image.png > image.ansi
cargo run --release --features cuda -- --backend cuda --size 80 image.png > image.ansi

Directory mode recursively mirrors PNG paths and changes their suffix to .ansi:

cargo run --release -- --size 80 corpus --output rendered

Only ANSI is written. Directory mode does not leave resized images or other intermediates behind.

Architecture note

The public Rust and Python APIs share decoding, resizing, structured frames, and ANSI emission. Rayon and CUDA implement interchangeable cell scorers.

Python

The PyPI distribution is chuda-ansi and its import name is chuda:

import chuda

renderer = chuda.Renderer("auto")
image = chuda.Image.open("image.png")
frame = renderer.render(image, 80)
ansi = frame.to_ansi()

Updating the symbol atlas

After updating the Chafa sources in vendor/chafa, run:

python3 tools/generate_symbols.py
cargo fmt

The generated atlas is LGPL-derived and this project is correspondingly licensed LGPL-3.0-or-later. See LICENSE and NOTICE.

Benchmark against Chafa

The benchmark excludes compilation, warms both programs once, and reports the median end-to-end batch time. It also writes one output from each renderer for visual inspection:

python3 tools/benchmark.py ../ansi-scaler/data/artifacts/rasters \
  --width 80 --images 100 --repeats 3
less -R benchmark-results/sample-chuda.ansi
less -R benchmark-results/sample-chafa.ansi

Machine-readable measurements are saved in benchmark-results/report.json.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chuda_ansi-0.2.3.tar.gz (63.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chuda_ansi-0.2.3-cp310-abi3-manylinux_2_35_x86_64.whl (842.0 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.35+ x86-64

File details

Details for the file chuda_ansi-0.2.3.tar.gz.

File metadata

  • Download URL: chuda_ansi-0.2.3.tar.gz
  • Upload date:
  • Size: 63.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for chuda_ansi-0.2.3.tar.gz
Algorithm Hash digest
SHA256 34ebece98c97d071860a387b62c7ecb703685b1046214f035f34ff91ff2c477b
MD5 231d5948952502451ac36bc29e189693
BLAKE2b-256 8e698890337915e2f3547bd6644b16a00b90ab2bb5512dde12501db6ba6f6215

See more details on using hashes here.

File details

Details for the file chuda_ansi-0.2.3-cp310-abi3-manylinux_2_35_x86_64.whl.

File metadata

File hashes

Hashes for chuda_ansi-0.2.3-cp310-abi3-manylinux_2_35_x86_64.whl
Algorithm Hash digest
SHA256 cc23f7b8bd1c534cba156c18dc568239416b0a733cf58447ca7c7e6310bf82d3
MD5 0b725310bbc3737c79cbc8066c8fd78c
BLAKE2b-256 e1b05894989d2997e7f6dc5ed6ca18e62632f56975394971afc63478d0659456

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page