使用python为jpegs创建缩略图
16lz
2021-01-22
As the title says i am looking for a way convert a huge number of images into thumbnails of different sizes , How do i go about doing this in python
由于标题说我正在寻找一种方法将大量图像转换为不同大小的缩略图,我如何在python中执行此操作
1 个解决方案
#1
16
See: http://www.pythonware.com/products/pil/index.htm
import os, sys
import Image
size = 128, 128
for infile in sys.argv[1:]:
outfile = os.path.splitext(infile)[0] + ".thumbnail"
if infile != outfile:
try:
im = Image.open(infile)
im.thumbnail(size)
im.save(outfile, "JPEG")
except IOError:
print "cannot create thumbnail for", infile
更多相关文章
- python 简单图像处理(2) 镜像
- caffe python批量抽取图像特征
- 在Python中显示来自控制台的图像
- Python为8bit深度图像应用color map
- Tensorflow:恢复图形和模型,然后在单个图像上运行评估
- python的PIL绘制多行文本的图像。
- 铯:使用自己的OpenStreetMap服务器。:“未能获得图像块”错误
- 如何将图像加载到PictureBox;基于存储在DataBase中的图像位置
- 使用进度条延迟加载图像会使图像在显示时发生损坏