参考资料:脚本之家https://www.jb51.net/article/204001.htm
- 1、图片的旋转rotate
- 2、图片的创建缩略图 thumbnail
- 3、使用crop实现抓屏
一、图片的旋转rotate
from PIL import Image
#显示图像
im = Image.open('santa.jpg')
im.show()
# 转换图像90度
im.rotate(90).show()
二、创建缩略图 thumbnail
- thumbnail
n. 拇指甲; 索引图像; (打印预览)略图;
adj. 微型的;简短的(论文等);
from PIL import Image
import glob, os
size = 128, 128
for infile in glob.glob('E:\opencv\*.jpg'):
print(infile)
filename = os.path.split(infile)[-1]
im = Image.open(infile)
im.thumbnail(size, Image.ANTIALIAS)
im.save("E:\opencv\\" + filename)
三、实现抓屏
from PIL import ImageGrab
#get current screen copy
image = ImageGrab.grab()
#display image size
print("Current screen shot size :",image.size)
#display image mode
print("Screen shot picture mode :", image.mode)
#save picture to screen-grab-1.bmp
image.save('screen-grab-1.bmp')
#show picture
image.show()
网友评论