美文网首页
图片的旋转、缩略图、抓屏

图片的旋转、缩略图、抓屏

作者: 大龙10 | 来源:发表于2022-02-05 06:20 被阅读0次
参考资料:脚本之家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()

相关文章

网友评论

      本文标题:图片的旋转、缩略图、抓屏

      本文链接:https://www.haomeiwen.com/subject/slcjkrtx.html