<分区>
我想用 Python 缩略图(将其调整为小尺寸)。
我该怎么做?
你知道有什么图书馆可以做这项工作吗?
<分区>
我想用 Python 缩略图(将其调整为小尺寸)。
我该怎么做?
你知道有什么图书馆可以做这项工作吗?
最佳答案
一个非常快速的谷歌搜索立即返回 this post :
size = 128, 128
try:
im = Image.open(infile)
im.thumbnail(size, Image.ANTIALIAS)
im.save(outfile, "JPEG")
except IOError:
print "cannot create thumbnail for '%s'" % infile
我使用的搜索词是 PIL
、Python
、resize
和 image
。您也可以尝试 thumbnail
。 Python 图像库 (PIL
) 是您想要用于此目的的工具。
关于python - 我如何使用 Python 缩略图,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15559232/
相关文章:
python - model.fit() Keras 分类多输入-单输出给出错误 : AttributeError: 'NoneType' object has no attribute 'fit'
python - 如果 foo 中不存在键,则忽略 str.format(**foo)
python - pyparsing operatorPredence : ability to add parseAction to parentheses blocks
python - 如何使用Python图像库(PIL)突出显示图像的一部分?
java - 使用 Graphics2D 使用亚像素级精度绘制图像