Simple Python package to display an image in the terminal by converting it into text
Project description
Image In Terminal
Simple Python package to display an image in the terminal by converting it into text. For the desired behavior to be achieved, the terminal must support colors and there should be no spacing between lines (0 line-spacing).
Installation
pip install image-in-terminal
How to use
You can use the package either from the terminal or from a script.
imageinterminal -h
usage:
imageinterminal image_uris [options]
iit image_uris [options]
positional arguments:
image_uris File path(s) or HTTP/HTTPS link(s) of the image(s) to be displayed. A directory can also be
passed in which case all supported images in the directory will be displayed.
options:
-h, --help show this help message and exit
-w WIDTH, --width WIDTH
Destination width of the image(s).
-wt WHITENESS_THRESHOLD, --whiteness-threshold WHITENESS_THRESHOLD
(float [0 - 1]). Pixels with a whiteness higher than this value will be inverted.
-dt DARKNESS_THRESHOLD, --darkness-threshold DARKNESS_THRESHOLD
(float [0 - 1]). Pixels with a whiteness lower than this value will be inverted.
-r, --recursive If a directory is passed as image_uri the image search will be recursively performed within
the directory passed and all its subdirectories.
-pp, --procedural-printing
The image(s) pixels will be printed one by one procedurally instead of printing/displaying the entire image at
once. Useful when printing/displaying high resolution images.
From the terminal:
imageinterminal "myImage.jpg"
iit "https://images/exampleImage.jpg" "myOtherImage.png" -w 128
iit "myImagesOnWhiteBackgrounds" -w 256 -wt 0.97
From a python script:
from imageinterminal import display_image
display_image("myImage.jpg")
Known Bugs
When the terminal is not zoomed out enough, at least the Windows Terminal, and a large image is printed, it can get bad formatted, as seen in the screenshot. When this happens, simply display the image again. For next time when printing a large image, first zoom out the contents of the terminal, and then display the image
Screenshots
JPG 1440x1800
JPG 256x256
PNG 256x256
Procedural Printing
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
Hashes for image_in_terminal-1.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5613bd84cc0712f3a3f588b46fdf6dfdbd00045f18ed5a8e0d25afe1feeb92a |
|
MD5 | f5bdb5e8dd73aa4b5accda9bb0a64957 |
|
BLAKE2b-256 | e51b536491432c2e7cf701cfbaef5e86de63bae5d357b4d47b6888d394593f68 |