获取指定文件夹下所有图片的名字、长和宽,长和宽,# home.zhenl
文章由Byrx.net分享于2019-03-23 10:03:16
获取指定文件夹下所有图片的名字、长和宽,长和宽,# home.zhenl
# home.zhenliang@gmail.com# http://t.qq.com/zhenliang# 获取指定文件夹下所有图片的名字、长和宽import os, sysfrom stat import *import ImagePicPathNameList = []PicWidthList = []PicHeightList = []def WalkTree(top, callback): for f in os.listdir(top): pathname = os.path.join(top, f) mode = os.stat(pathname)[ST_MODE] if S_ISDIR(mode): WalkTree(pathname, callback) elif S_ISREG(mode): callback(pathname) else: print 'Skipping %s' % pathnamedef GetPicInfo(file): global PicPathNameList global PicWidthList global PicHeightList try: image = Image.open(file) PicPathNameList.append(file) PicWidthList.append(image.size[0]) PicHeightList.append(image.size[1]) except IOError: passif __name__ == '__main__': WalkTree(top, GetPicInfo) print "PicPathNameList Begin" print PicPathNameList print PicWidthList print PicHeightList print "PicPathNameList End"
相关内容
- 过滤掉文件中的指定邮箱地址,过滤邮箱地址,#coding=
- 子网掩码格式转换,,#!/usr/bin/e
- python实现文件快照加密保护,,# Hello, thi
- python urllib.urlencode用法演示,,>>> import u
- Multidimensional Pareto front,,import numpy
- python查找两个字符串中相同的字符并输出,python字符串
- python文件拷贝代码,,import shuti
- python正则搜索范例,python搜索范例,# encoding:
- 用Vim为Python源码自动添加#!行和编码行,,function Ins
- python生成随机数代码,python生成随机数,import rando
评论关闭