How to display a jpg file in Python?


Question

def show():

    file = raw_input("What is the name of the image file? ")

    picture = Image(file)

    width, height = picture.size()

    pix = picture.getPixels()

I am trying to write a code to display this image but this code does not provide the image. How to change my code in order to display this image?

1
22
10/6/2015 5:03:31 AM

Accepted Answer

import Image

image = Image.open('File.jpg')
image.show()
44
3/16/2011 11:59:27 PM

Don't forget to include

import Image

In order to show it use this :

Image.open('pathToFile').show()

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon