python - 我如何使用 Python 缩略图

标签 python image

<分区>

我想用 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

我使用的搜索词是 PILPythonresizeimage。您也可以尝试 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 使用亚像素级精度绘制图像

php - 从php中的本地服务器文件夹中删除图像

html - 除非更改名称,否则浏览器不会加载优化图像

python - NumPy 。将一个数组中的所有向量行与同一数组中的所有其他向量行进行比较

Python加权随机

image - 设置 div 背景图像以适合其大小?