【发布时间】:2018-09-15 01:55:58
【问题描述】:
我调整图像大小的代码是:
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')
我尝试过的是:
.ANTIALIAShttps://pillow.readthedocs.io/en/3.1.x/reference/Image.html#PIL.Image.Image.resize以外的不同选项
保存img.save('/home/user/Desktop/test_pic/change.png',quality=95)时添加参数quality
转换为 rgb img = img.convert("RGB").resize((wsize,hsize), Image.ANTIALIAS)
问题是我的图像在原始图像中充满了小文本,因此在调整它们的大小以便能够进一步处理甚至阅读它们时确实需要一个好的结果。
【问题讨论】:
-
试试
img = img.convert("RGB").resize(wsize,hsize).quantize() -
给出了这个错误
ValueError: unknown resampling filter
标签: python python-3.x image image-processing python-imaging-library