Skip to main content

Display images in terminals using Unicode mosaics and ANSI colors

Project description

catpic

Turn images into terminal eye candy using Unicode mosaics and ANSI colors.

The twist: Save as MEOW format and display with cat. Yes, the POSIX command. No special viewer needed.

catpic photo.jpg -o photo.meow
cat photo.meow  # 🐱 Just works

What are Glyxels?

Glyxels (glyph + pixels) are what happens when you treat each terminal character as a tiny canvas. catpic uses the EnGlyph algorithm to subdivide characters into grids—for example, BASIS 2×4 means each character represents 8 glyxels (2 wide, 4 tall).

The magic:

  1. Slice your image into character-sized cells
  2. Find the two most important colors in each cell
  3. Pick the Unicode character that matches the glyxel pattern
  4. Paint it with ANSI true-color

Result? A standard 80×24 terminal becomes a 160×96 glyxel display. Not bad for text.

Features

  • cat-compatible format: MEOW files display with standard POSIX cat
  • Multiple BASIS levels: Trade speed for quality (1×2 to 2×4)
  • Smooth animations: GIF playback with no flicker
  • Primitives API: Build your own TUI graphics with composable functions
  • Environment aware: Automatic terminal size and aspect ratio detection
  • Multi-language: Python (stable), C (in development), Rust/Go (planned)

Installation & Usage

See IMPLEMENTATION.md for installation instructions and API documentation for your language.

Each implementation provides the same core functionality with language-appropriate APIs and conventions.

Environment Variables

catpic respects these environment variables for configuration:

CATPIC_BASIS

Set your preferred BASIS quality level:

export CATPIC_BASIS=2,4
catpic photo.jpg  # Uses ultra quality by default

Supported formats: 1,2 | 2,2 | 2,3 | 2,4
(You can also use x or _ as separator: 2x4 or 2_4)

Add to your shell profile (~/.bashrc, ~/.zshrc, etc.) to make permanent.

CATPIC_CHAR_ASPECT

Set terminal character aspect ratio to fix image proportions:

export CATPIC_CHAR_ASPECT=2.0
catpic photo.jpg

Common values:

  • 2.0 - Most terminals (default)
  • 1.8 - Wider fonts
  • 2.2 - Narrower fonts

Why this matters: Terminal characters are typically taller than they are wide. If your images look squashed (too wide) or stretched (too tall), adjust this value to match your terminal's font proportions.

Quick calibration:

If you have a test image with a circle:

catpic circle.png

# If circle looks tall/narrow, decrease:
export CATPIC_CHAR_ASPECT=1.8
catpic circle.png

# If circle looks wide/squashed, increase:
export CATPIC_CHAR_ASPECT=2.2
catpic circle.png

Once calibrated for your terminal, add to your shell profile.

How BASIS Works

BASIS (x, y) defines the glyxel grid per character:

  • 1×2 (4 patterns): Fast, chunky. Good for large images or overviews.
  • 2×2 (16 patterns): Balanced. Default for most use cases.
  • 2×3 (64 patterns): Smooth gradients. Sextant blocks.
  • 2×4 (256 patterns): Maximum detail. Braille patterns.

Higher BASIS = more glyxels per character = better quality, slower rendering.

MEOW Format

Mosaic Encoding Over Wire—glyxel images as plain text with ANSI escape codes.

MEOW files are cat-compatible: they're standard text with embedded metadata and ANSI color codes. No special viewer needed.

Current version: 0.6 (uses OSC 9876 escape sequences for metadata)

Example usage:

# Create
catpic sunset.jpg -o sunset.meow

# Display (any of these work)
cat sunset.meow
less -R sunset.meow
head -n 30 sunset.meow  # Preview

MEOW files contain:

  • Canvas metadata (size, animation settings, BASIS)
  • Layer metadata (position, transparency, frame timing)
  • Standard ANSI escape codes for colors
  • Unicode characters encoding glyxel patterns

Format specification: See spec/meow_v06_specification.md

Project Structure

catpic is designed as a multi-language project with consistent behavior:

catpic/
├── python/              # Python reference implementation (stable)
├── c/                   # C implementation (in development)
├── rust/                # Rust implementation (planned)
├── go/                  # Go implementation (planned)
├── docs/                # Architecture and API documentation
├── spec/                # MEOW format and compliance specifications
└── benchmarks/          # Performance comparisons

All implementations:

  • Support the identical MEOW format
  • Pass the same compliance test suite
  • Implement the EnGlyph algorithm consistently
  • Support all BASIS levels

Language-specific APIs differ to match ecosystem conventions.

Documentation

Contributing

Contributions welcome! See CONTRIBUTING.md for:

  • Code style and testing requirements
  • How to add new BASIS levels
  • Cross-language implementation guidelines
  • Prospective features (Sixel/Kitty graphics, streaming, etc.)

License

MIT—do whatever you want with it.

See Also


Built with Claude (Anthropic) exploring terminal graphics techniques that don't suck.

Project details


Download files

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

Source Distribution

catpic-0.6.0.tar.gz (73.6 kB view details)

Uploaded Source

Built Distribution

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

catpic-0.6.0-py3-none-any.whl (40.3 kB view details)

Uploaded Python 3

File details

Details for the file catpic-0.6.0.tar.gz.

File metadata

  • Download URL: catpic-0.6.0.tar.gz
  • Upload date:
  • Size: 73.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.29

File hashes

Hashes for catpic-0.6.0.tar.gz
Algorithm Hash digest
SHA256 1367bdf359d778dfb9f4e5cd8cdd1a5449bc56446900598cbe7b0de42ca6a144
MD5 4fa2e3590938e03d9347cd6045f3eb91
BLAKE2b-256 3801724dc395712fdfdafca8c3ada4e103a6eec1c52c70dd0c22bbfd1677af53

See more details on using hashes here.

File details

Details for the file catpic-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: catpic-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 40.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.29

File hashes

Hashes for catpic-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fbb559df87e1f3dc763e6bdf301ebacd423b68c081761d73842239880fe2ad1d
MD5 37c9e946664c481b23bb054eb31232e2
BLAKE2b-256 1d7fa185d2b9588d8c96cf8fc708f18bd8144740e0892aa32968a09fa33f20b1

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