Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display a jpg file in Python? [duplicate]

Tags:

python

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?

like image 394
hkus10 Avatar asked Mar 16 '11 23:03

hkus10


2 Answers

from PIL import Image

image = Image.open('File.jpg')
image.show()
like image 59
tiagoboldt Avatar answered Dec 06 '22 22:12

tiagoboldt


Don't forget to include

import Image

In order to show it use this :

Image.open('pathToFile').show()
like image 38
dLobatog Avatar answered Dec 06 '22 21:12

dLobatog