Convert images to beautiful ANSI escape codes
Project description
CLImage
Convert images to beautiful ANSI escape codes for display in command line interfaces.
Available as both a CLI application and a Python library.
Features
- 8/16/256/Truecolor supports
- Custom system color palettes
- Toggleable Unicode mode, allowing up to 4x more detail
- Custom output size
Example usage
CLI
$ climage --unicode --truecolor --cols 80 barney.jpg
For more detail and available options, run $ climage --help
.
Python
import climage
output = climage.convert('image.png', is_unicode=True)
print(output)
# Converting downloaded file
from PIL import Image
import requests
response = requests.get('https://www.python.org/static/community_logos/python-logo-master-v3-TM-flattened.png')
# Convert to RGB, as files on the Internet may be greyscale, which are not
# supported.
img = Image.open(BytesIO(response.content)).convert('RGB')
# Convert the image to 80col, in 256 color mode, using unicode for higher def.
converted = climage.convert_pil(img, is_unicode=True)
print(converted)
# Convert the image into 50px * 50px, as the convert_array function does not
# perform resizing.
img = Image.open('image.png').convert('RGB').resize((50, 50))
arr = np.array(img)
output = climage.convert_array(arr, is_unicode=True)
print(output)
View additional examples on the project homepage.
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
climage-0.2.0.tar.gz
(23.1 kB
view hashes)
Built Distribution
climage-0.2.0-py3-none-any.whl
(21.5 kB
view hashes)