Python Imaging Library: ImageGrab Module(图像采集模块)
2017-10-30 19:10
417 查看
Python Imaging Library: ImageGrab Module(图像采集模块)
ImageGrab可以用来将屏幕或剪贴板的内容复制到一个图像内存中。目前的版本只在Windows上运行。
(版本1.1.3)获取屏幕快照,并返回一个“RGB”图像。边界框参数可用于仅复制屏幕的一部分。
(版本1.1.3)获取剪贴板内容的快照,并返回一个图像对象或一个文件名列表。如果剪贴板不包含图像数据,那么这个函数将返回None。
您可以使用isinstance来检查函数是否返回了一个有效的图像对象,或者其他什么:
im = ImageGrab.grabclipboard()
if isinstance(im, Image.Image):
... got an image ...
elif im:
for filename in im:
try:
im = Image.open(filename)
except IOError:
pass # ignore this file
else:
... got an image ...
else:
... clipboard empty ...
ImageGrab可以用来将屏幕或剪贴板的内容复制到一个图像内存中。目前的版本只在Windows上运行。
函数
grab
ImageGrab.grab() ⇒ image
ImageGrab.grab(bbox) ⇒ image
(版本1.1.3)获取屏幕快照,并返回一个“RGB”图像。边界框参数可用于仅复制屏幕的一部分。
grabclipboard
ImageGrab.grabclipboard() ⇒ image or list of strings or None
(版本1.1.3)获取剪贴板内容的快照,并返回一个图像对象或一个文件名列表。如果剪贴板不包含图像数据,那么这个函数将返回None。您可以使用isinstance来检查函数是否返回了一个有效的图像对象,或者其他什么:
im = ImageGrab.grabclipboard()
if isinstance(im, Image.Image):
... got an image ...
elif im:
for filename in im:
try:
im = Image.open(filename)
except IOError:
pass # ignore this file
else:
... got an image ...
else:
... clipboard empty ...
相关文章推荐
- Python Imaging Library: ImageStat Module(图像统计模块)
- Python Imaging Library: ImagePath Module(图像路径模块)
- Python Imaging Library:ImageDraw Module(图像绘制模块)
- Python Imaging Library: ImageFile Module(图像文件模块)
- Python Imaging Library: ImageQt Module(图像QT模块)
- Python Imaging Library: ImageOps Module(图像运算模块)
- Python Imaging Library: ImageMath Module(图像数学运算模块)
- Python Imaging Library: ImageEnhance Module(图像增强模块)
- Python Imaging Library: ImageSequence Module(图像序列模块)
- Python Imaging Library: ImageWin Module(图像Windows模块)
- Python Imaging Library: ImageColor Module(图像颜色模块)
- Python Imaging Library: ImageTk Module(图像Tkinter模块)
- Python Imaging Library: ImageFilter Module(图像滤波模块)
- Python Imaging Library: PSDraw Module(Postscript打印机模块)
- Python Imaging Library: ImageChops Module(图像通道操作模块)
- OpenCV学习笔记12 OpenCV图像处理模块ImgProc Module. Image Processing(五)
- [置顶] 【python 图像处理】Python图像处理模块pillow子模块Image用法精要
- Python图像处理库PIL的Image模块介绍(五)
- Python图像处理库PIL的ImageFile模块介绍
- Python图形图像处理库的介绍之Image模块.