Turns images into ASCII art. This is just the core library; make sure to install some extras, too.
Project description
image2ascii-core
This is a thing that makes fancy ANSI graphics out of image files. And not just by sloppily repeating the same character all over the place; no, it detects transparency and draws edges with .od$$o.o$$bo. etc, like a real little ANSI artist.
It's an almost complete rewrite of an old project of mine. It's pretty versatile. You can adjust sizes, colour balance, contrast, define your own colour converters, shape sets, etc.
There is a CLI tool in a separate repo. More info will probably come soon.
Optimization/benchmarking
Image resizing methods
Benchmarking the different PIL.Image.Resampling methods when downsizing an 1833x1380 image to 18x13:
NEAREST: 3.05 μs ± 50.6 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)
BOX: 3.93 ms ± 48.8 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)
HAMMING: 7.28 ms ± 24 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)
BILINEAR: 7.3 ms ± 137 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)
BICUBIC: 13.3 ms ± 43.2 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)
LANCZOS: 19.5 ms ± 34.2 μs per loop (mean ± std. dev. of 7 runs, 100 loops each)
(NEAREST is more than a thousand times faster than the runner-up!)
And when upsizing the same image to 18300x13800:
NEAREST: 696 ms ± 11.5 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
BOX: 1.75 s ± 11.7 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
BILINEAR: 2.13 s ± 48.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
HAMMING: 2.13 s ± 16.6 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
BICUBIC: 2.88 s ± 14.4 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
LANCZOS: 3.69 s ± 121 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
(Just a 2.5x lead for NEAREST here.)
Image section colour inference methods
Inferring colour for an RGBA array of shape=(29, 4):
MEDIAN: 2.11 μs ± 29.1 ns per loop (mean ± std. dev. of 7 runs, 100,000 loops each)
MOST_COMMON: 25.4 μs ± 910 ns per loop (mean ± std. dev. of 7 runs, 10,000 loops each)
ColorInferenceMethod.MEDIAN is more than 10x faster.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file image2ascii_core-0.8.0.tar.gz.
File metadata
- Download URL: image2ascii_core-0.8.0.tar.gz
- Upload date:
- Size: 248.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b1bc0941344e56436197998611d643a327a21c39c6b6f948e7422d6047e21fca
|
|
| MD5 |
01e534c5e1d3c8ce40d7e7d00bf0eb9d
|
|
| BLAKE2b-256 |
a1c47b29798deae97ec8db1b1357be517e0201917c3e2d9244fffb55dcf970a0
|
File details
Details for the file image2ascii_core-0.8.0-py3-none-any.whl.
File metadata
- Download URL: image2ascii_core-0.8.0-py3-none-any.whl
- Upload date:
- Size: 253.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6df9b5093d3ac150e267c5d5c5a6780781f7bb9d8a4e96be9fa358e269e9790
|
|
| MD5 |
ccd9a239f43278787accfb97ea0af098
|
|
| BLAKE2b-256 |
e9fdb9854ab2ccb92ab3e12d0f44081dd75ab95f2072f9da5ab5981422925459
|