pythonimage

Showing an image from console in Python


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?


Solution

  • 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.