Pillow用法

cooolr 于 2021-12-01 发布
pip install pillow
from PIL import Image
img = Image.open("filename.jpg")
from io import BytesIO

img = Image.open(BytesIO(b"..."))
print(img.format)
print(Image.MIME[img.format])
width, height = img.size
img = img.resize((int(width/2), int(height/2)))
img = img.convert("L")
img.save("filename.jpg")