我的调整图像大小的代码是:
from PIL import Image
ratio = 0.2
img = Image.open('/home/user/Desktop/test_pic/1-0.png')
hsize = int((float(img.size[1])*float(ratio)))
wsize = int((float(img.size[0])*float(ratio)))
img = img.resize((wsize,hsize), Image.ANTIALIAS)
img.save('/home/user/Desktop/test_pic/change.png')
我尝试过的方法是:
除了.ANTIALIAS
https://pillow.readthedocs.io/en/3.1.x/reference/Image.html#PIL.Image.Image.resize之外的不同选项
在保存时添加参数quality
img.save('/home/user/Desktop/test_pic/change.png',quality=95)
转换为rgbimg = img.convert("RGB").resize((wsize,hsize), Image.ANTIALIAS)
问题在于我的图像原始图像中充满小文本,因此当它们被调整大小以进一步处理甚至阅读它们时,我真的需要一个很好的结果。
img = img.convert("RGB").resize(wsize,hsize).quantize()
- Mick_ValueError: 未知的重采样滤波器
。 - Jess