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

更多相关文章

  1. python 简单图像处理(2) 镜像
  2. caffe python批量抽取图像特征
  3. 在Python中显示来自控制台的图像
  4. Python为8bit深度图像应用color map
  5. Tensorflow:恢复图形和模型,然后在单个图像上运行评估
  6. python的PIL绘制多行文本的图像。
  7. 铯:使用自己的OpenStreetMap服务器。:“未能获得图像块”错误
  8. 如何将图像加载到PictureBox;基于存储在DataBase中的图像位置
  9. 使用进度条延迟加载图像会使图像在显示时发生损坏

随机推荐

  1. __builtin_clz(); __builtin_ctz(); __bu
  2. android 布局边框阴影1dp
  3. 【源码分享下载】每日更新之Android快速
  4. android通知栏进度条
  5. Android 之 shape和selector用法介绍
  6. Android(安卓)Color值汇总
  7. Android studio中快捷键
  8. Android---进程间通机制的简单理解
  9. Android 更新UI的两种方法——handler和r
  10. Android下拉框控件Spinner的使用