Python PIL批量处理处理图片,,图片太大了,上百张图用p
Python PIL批量处理处理图片,,图片太大了,上百张图用p
图片太大了,上百张图用photoshop改太慢,就想到用python写个简单的批处理。功能简单就是把原图按比例缩小
# -*- coding: cp936 -*- import Image import glob, os #图片批处理 def timage(): for files in glob.glob('D:\\\\1\\\\*.JPG'): filepath,filename = os.path.split(files) filterame,exts = os.path.splitext(filename) #输出路径 opfile = r'D:\\\\22\\\\' #判断opfile是否存在,不存在则创建 if (os.path.isdir(opfile)==False): os.mkdir(opfile) im = Image.open(files) w,h = im.size #im_ss = im.resize((400,400)) #im_ss = im.convert('P') im_ss = im.resize((int(w*0.12), int(h*0.12))) im_ss.save(opfile+filterame+'.jpg') if __name__=='__main__': timage() print '哈哈完蛋啦'#该片段来自于http://byrx.net
相关内容
- Python 简单的备份文件脚本,python备份脚本,#! /usr/bin/
- Python 神经网络调教程序,python神经网络调教,import ran
- Python 代码行数统计程序,python行数统计程序,import sys
- Python 相似单词,Python单词,给你一个单词a,如果通过
- Django 简化view函数的编写,django简化view函数,1.定义包装
- Python 脚本文件批量改名,,#!/usr/bin/e
- Python 清除CVS和SVN下的目录和子目录,cvssvn,#!/usr/bin/e
- Python 修改MP3,python修改mp3,用这个程序修改后的MP3
- Python 抓取新浪读书频道小说,,#!/usr/bin/e
- Python 连接MySQ和MSSQL,pythonmysqmssql,host = ''
评论关闭