在python中使用pillow修改圖片的尺寸大小
from PIL import Image
readfile_path=r'./template.png'? #當(dāng)前圖片的路徑(相對路徑)
outfile_path=r'./template.png'? #圖片保存在當(dāng)前路徑
width=38? #寬度
length=38? #長度
Image.open(readfile_path).convert('RGB').save(outfile_path) # convert the image to RGB mode? very important 將圖片轉(zhuǎn)化為RGB模式
img = Image.open(readfile_path)
print(img.format, img.size, img.mode, img.info)
newImg = img.resize((width,length), Image.ANTIALIAS)? #想調(diào)整的大小
print(newImg)
newImg.save(outfile_path)