#image #pixel-art #terminal-art #image-cli #terminal

bin+lib px2ansi-rs

Convert pixel art images to ANSI terminal art (Rust port)

6 releases

Uses new Rust 2024

0.2.5 Jan 29, 2026
0.2.4 Jan 28, 2026
0.1.1 Jan 24, 2026

#5 in Rendering


Used in slasher-horrorscripts

GPL-3.0 license

22KB
128 lines

px2ansi

A high-performance Rust port of px2ansi.

px2ansi converts pixel art images into ANSI escape codes for display in modern terminals. It uses 24-bit truecolor and unicode half-block characters ( / ) to render images with precision.

It is significantly faster than the original Python implementation and ships as a single, static binary.

(Before) screenshot1

(After) screenshot2

Features

  • 🚀 Fast: Written in Rust, optimized for speed (~25x faster than Python).

  • 🎨 Truecolor: Supports full 24-bit RGB colors.

  • 📐 Smart Resizing: Automatically detects terminal width and resizes large images to fit.

  • 🖼️ Flexible Filtering: Choose between sharp pixel art (nearest) or smooth high-res downscaling (lanczos3).

  • 🧩 Transparency: Correctly handles alpha channels (rendering transparent pixels as terminal background).

  • 📦 Simple: Single binary, no dependencies required at runtime.

Installation

From Source

git clone https://github.com/saylesss88/px2ansi-rs
cd px2ansi-rs
cargo install --path .

crates.io

cargo install px2ansi-rs

Usage

Basic

Convert an image and print to stdout (auto-resizes to fit your terminal):

px2ansi-rs image.png

Advanced Options

Resize filters:

Use --filter to control how the image is downscaled.

  • Pixel Art (Pikachu, sprites): Use nearest to keep sharp edges.
px2ansi-rs sprite.png --filter nearest
  • Photos / Logos: Default (Lanczos3) works best.
px2ansi-rs photo.jpg

Manual Sizing(WIP):

px2ansi-rs huge_screenshot.png --width 100
px2ansi-rs pikachu.png --filter=nearest --width 50

Save output to a file:

px2ansi-rs image.png -o art.txt

Try it out!

You can test it right now with the included test.png (a small pixel art example if you cloned the repo):

px2ansi-rs tests/test.png

Dependencies

~11–24MB
~345K SLoC