Skip to main content

Rich Pixels

A Rich-compatible library for writing pixel images and other colourful grids to the terminal.

Installation

Get rich-pixels from PyPI.

pip install rich-pixels

Basic Usage

Images

Image from a file

You can load an image file from a path using from_image_path:

from rich_pixels import Pixels
from rich.console import Console

console = Console()
pixels = Pixels.from_image_path("pokemon/bulbasaur.png")
console.print(pixels)

Pillow image object

You can create a PIL image object yourself and pass it in to from_image.

from rich_pixels import Pixels
from rich.console import Console
from PIL import Image

console = Console()

with Image.open("path/to/image.png") as image:
    pixels = Pixels.from_image(image)

console.print(pixels)

Using this approach means you can modify your PIL Image beforehard.

ASCII Art

You can quickly build shapes using a tool like asciiflow, and apply styles the ASCII characters. This provides a quick way of sketching out shapes.

from rich_pixels import Pixels
from rich.console import Console

console = Console()

# Draw your shapes using any character you want
grid = """\
     xx   xx
     ox   ox
     Ox   Ox
xx             xx
xxxxxxxxxxxxxxxxx
"""

# Map characters to different characters/styles
mapping = {
    "x": Segment(" ", Style.parse("yellow on yellow")),
    "o": Segment(" ", Style.parse("on white")),
    "O": Segment(" ", Style.parse("on blue")),
}

pixels = Pixels.from_ascii(grid, mapping)
console.print(pixels)

Using with Textual

Pixels can be integrated into Textual applications just like any other Rich renderable.

Metadata

Release files for rich-pixels 3.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rich-pixels 3.0.1
File Size Uploaded
rich_pixels-3.0.1.tar.gz 24.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rich-pixels 3.0.1
File Interpreter ABI Platform
rich_pixels-3.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 30.6 kB

Release files / rich_pixels-3.0.1.tar.gz

Download URL rich_pixels-3.0.1.tar.gz
Size 24.6 kB
Tags Source
SHA-256 checksum
How to use checksums
4a81977d45437ce5009cdcaf70af80256c3bdfab870e87ab802c577ba4133235
BLAKE2b-256 checksum
How to use checksums
31716d5cd4b8d67cd49366eda19aaf37f20094ce562223a91166109202590237
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.1

Release files / rich_pixels-3.0.1-py3-none-any.whl

Download URL rich_pixels-3.0.1-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e82c5aa0d00885609675494f16e1ef814c68fa795634f1d6917cae9159b755e1
BLAKE2b-256 checksum
How to use checksums
08727264494bc0944db1166b73c88f19d9ddfc584dbbc77c210cd0f52f59c511
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.12.1

Release history Release notifications | RSS feed

This release

3.0.1 This release

2 release files

3.0.0

2 release files

2.2.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page