2011-03-16 75 views
13
def show(): 

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

    picture = Image(file) 

    width, height = picture.size() 

    pix = picture.getPixels() 

我想寫一個代碼來顯示此圖像,但此代碼不提供圖像。 如何更改我的代碼以顯示此圖像?如何在Python中顯示jpg文件?

+1

記得要選擇一個公認的答案對你的問題,以便其他可能從中受益以及。 – tiagoboldt 2011-03-17 00:11:07

+0

請搜索。請。這是一個重複的問題。所有這些都是相關的。 http://stackoverflow.com/search?q=python+display+image – 2011-03-17 00:18:51

回答

29
import Image 

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

這只是啓動一個外部查看器應用程序 – endolith 2017-07-04 01:02:01

15

不要忘了包括

import Image 

爲了顯示它使用:

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

有第二個地方砰砰聲 – easymoden00b 2015-07-06 18:47:41