PIL for python (also,Tkinter)

来源:互联网 发布:微星主板编程器jsp1 编辑:程序博客网 时间:2024/05/17 03:45


PIL  process  Image  Library

提前下载 PIL库

http://www.pythonware.com/products/pil/

下载对应的python版本的

安装之后在  D:\Program Files\python2.7.6\Lib\site-packages 目录下,就出现了  PIL目录啦。

显示一幅图像:

from PIL import Image, ImageTkimg = Image.open('10.bmp')print img.format, img.size, img.modeimg.show()

更多: http://www.oschina.net/question/89964_40268

====================

PS:

用 Tkinter 打开图像显示:


python 的 TK接口调用GUI的  打开图片的函数 默认的是  打开的  gif  的图像


from Tkinter import *#创建一个画布canvas = Canvas(width=800, height=600, bg='green')#start  your  canvas#在画布上加载图片im = PhotoImage(file = 'C:\\lh.gif') #使用PhotoImage打开图片【TK默认加载的是gif格式的图片】canvas.create_image(30, 50, image = im) #使用create_image将图片添加到Canvas组件中#end canvas.pack(expand=YES, fill=BOTH)  #将canvas添加到主窗口  mainloop()  #应该是让画布一直显示的吧



原创粉丝点击