开发者

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

开发者 https://www.devze.com 2023-02-17 12:46 出处:网络
This question already has answers here: Showing an image from console in Python (15 answers) Closed 6 years ago.
This question already has answers here: Showing an image from console in Python (15 answers) Closed 6 years ago.
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 pro开发者_C百科vide the image. How to change my code in order to display this image?


from PIL import Image

image = Image.open('File.jpg')
image.show()


Don't forget to include

import Image

In order to show it use this :

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号