Skip to main content

No project description provided

Project description

image2ascii-core

thisprojectwascodedbyahumanbeing-wordart

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.

image

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


Download files

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

Source Distribution

image2ascii_core-0.7.1.tar.gz (248.1 kB view details)

Uploaded Source

Built Distribution

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

image2ascii_core-0.7.1-py3-none-any.whl (252.9 kB view details)

Uploaded Python 3

File details

Details for the file image2ascii_core-0.7.1.tar.gz.

File metadata

  • Download URL: image2ascii_core-0.7.1.tar.gz
  • Upload date:
  • Size: 248.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.7

File hashes

Hashes for image2ascii_core-0.7.1.tar.gz
Algorithm Hash digest
SHA256 c9ef546855002589721e6765dc5138b5a88afe81a9782cffa8b984111457b4d4
MD5 dc47079bc2f72c44f02e8383f42991d0
BLAKE2b-256 a99bad53c60145898f1a7fde2706100766e212974b3b5117b05d50da17294a6b

See more details on using hashes here.

File details

Details for the file image2ascii_core-0.7.1-py3-none-any.whl.

File metadata

File hashes

Hashes for image2ascii_core-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d129a2d733bb1395edefe1db4401c239614c100e08750996ed1bd568d465a181
MD5 60967233c7934a6fbaf2ff257568a521
BLAKE2b-256 f531fc5912b9b5b53d0a3c8d2899a54e91818688b7e48d30f03d29d38e8cad47

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