Pillow库是一个Python图像处理库,可以用来处理图像,包括打开、保存、创建、编辑和转换图片。一些主要的方法包括:
打开和保存图像:from PIL import Image# 打开图像image = Image.open('example.jpg')# 保存图像image.save('output.jpg')调整图像大小:from PIL import Image# 打开图像image = Image.open('example.jpg')# 调整图像大小new_size = (100, 100)resized_image = image.resize(new_size)图像旋转:from PIL import Image# 打开图像image = Image.open('example.jpg')# 旋转图像rotated_image = image.rotate(90)图像滤镜:from PIL import Imagefrom PIL import ImageFilter# 打开图像image = Image.open('example.jpg')# 应用滤镜blurred_image = image.filter(ImageFilter.BLUR)这些只是一些Pillow库中可用的方法,还有很多其他的方法可以用来处理图像。更多信息可以查阅Pillow库的官方文档。




