Elliot A.
Elliot A.

Reputation: 1581

Can you print an image to the terminal using python?

You can print to the terminal using print("Hello World") but can you print an image? If you can, how?

Upvotes: 2

Views: 10289

Answers (2)

jcubic
jcubic

Reputation: 66478

It's possible with ANSI art (that use ANSI escape codes), Check this JavaScript library https://github.com/patmooney/node-terminal-art

enter image description here

or web browser that render web pages in terminal https://www.brow.sh/ (including images).

enter image description here

As you can see this is possible, terminal give you this, so you can implement such a library in any language or search if there is already one in Python.

EDIT some terminals also support Sixel format that allow o render bigger resolution images.

Upvotes: 2

Ethan Furman
Ethan Furman

Reputation: 69021

If by print an image you mean displaying the pretty graphic, no. If you mean printing something that kinda/sorta if you stand back a bit and squint looks like the image (otherwise knows as ascii art), then yes -- if you have a library that supports converting from binary.

Upvotes: 4

Related Questions