Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Showing an image from console in Python

Tags:

python

image

What is the easiest way to show a .jpg or .gif image from Python console?

I've got a Python console program that is checking a data set which contains links to images stored locally. How should I write the script so that it would display images pop-up graphical windows?

like image 413
Alex Avatar asked Sep 11 '09 22:09

Alex


People also ask

Can you display images in console?

Console applications are used primarily for text only applications. There is no way to display an image. You could launch another application which does display the image. This other application would most likely need to support a command line option to pass an image to it.


1 Answers

Using the awesome Pillow library:

>>> from PIL import Image                                                                                 >>> img = Image.open('test.png') >>> img.show()  

This will open the image in your default image viewer.

like image 157
Steven Kryskalla Avatar answered Oct 02 '22 16:10

Steven Kryskalla