PIL 图像旋转并保存

from PIL import Image

# 读取图片
img = Image.open(r'./000001.jpg')

# 转化为alpha层
img_alpha = img.convert('RGBA')

# 旋转图像
rot = img_alpha.rotate(45, expand = 1)

# 与旋转图像大小相同的白色区域
fff = Image.new('RGBA', rot.size, (255,255,255,255))

# # 使用rot作为创建一个复合图像
out = Image.composite(rot, fff, mask=rot)


out.convert(img.mode).show()
# out.convert(img.mode).save("./1.jpg")

猜你喜欢

转载自blog.csdn.net/luolinll1212/article/details/83059118
PIL
今日推荐