Reads image formats and prints ascii colour text to console
Project description
consoleimages
Reads image formats and prints ascii colour text to console
Create an instance of the image
class passing the path of a image as an argument.
Instance arguments:
- width
(of astext
string)
- height
(of astext
string)
- aspect_ratio
(width
/height
)
- astext
(string that gets printed to the console)
- name
(the name of the image file)
- display()
(pass a file to write to, otherwise sys.stdout)
Example:
from os import get_terminal_size, listdir
from os.path import isfile, join
from time import sleep
from consoleimages import image
def clear():
from os import system
from sys import platform
system("cls" if platform == "win32" else "clear") # clears the console
images = {}
while True:
for imagename in [f for f in listdir("images/") if isfile(join("images/", f))]: # open the 'images/' directory and get all the file names inside.
clear() # clear console
images[imagename] = image("images/" + imagename, get_terminal_size()[1] - 4) # create instance of image class
print(images[imagename].name) # print the name of the image in that instance
images[imagename].display() # print the image
print(images[imagename].width, images[imagename].height, sep=" x ", end=" (" + str(images[imagename].aspect_ratio) + ")\n") # print the width, height and aspect ratio
sleep(2) # wait 2 seconds
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
consoleimages-1.0.0.tar.gz
(2.5 kB
view details)
Built Distribution
File details
Details for the file consoleimages-1.0.0.tar.gz
.
File metadata
- Download URL: consoleimages-1.0.0.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.8.0 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b882b4df13408dc6ab41d2748f3cf1ff8ac2b98c1ba60df01419e754da216a1 |
|
MD5 | 3cce0295d1b34ed19c2c92312695e766 |
|
BLAKE2b-256 | 207e428f5d29d1533c1fb25b51cae1d3e20349f0ef9ade8711b5f33083b5b9b3 |
File details
Details for the file consoleimages-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: consoleimages-1.0.0-py3-none-any.whl
- Upload date:
- Size: 2.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.8.0 tqdm/4.48.2 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3231a6ee0bf9f779c9d8c58f582f19387c4fad5b37a4da6628744733ec63d423 |
|
MD5 | 3765f637ccdcfe6cfa692f7c548e1c80 |
|
BLAKE2b-256 | ad475a5f144c4f17de2ef41498ed43805fe658583ec11daea4e833daf11f256d |