python批量处理图片属性_python PIL 批量处理处理图片
python PIL 批量處理處理圖片
客戶給一堆圖片要傳到后臺,圖片太大了,上百張圖用photoshop改太慢,就想到用python寫個簡單的批處理。功能簡單就是把原圖按比例縮小,代碼更簡單 20多行。
# -*- 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 '哈哈完蛋啦'
相關文檔:
今天看了序列類型相關的比較操作.
在python核心編程(2nd)一書中6.13.1章節中, 給出了列表比較的一個準則..
個人感覺還是不很完善:
如果掃描到兩個列表中當前比較元素是不可比較的, 那么返回什么??
我用的是python2.6....
對這個問題做了一些測試, 自己目前嘎絕當比較遇到上述情況時, 是使用兩個列表的內存地址值來比� ......
ZoundryDocument
Python skin is known for its color variations and for its elasticity; it is
the warmest leather of the season and ideal for the manufacture of many luxury
goods. Sometimes natural patterns can be hidden when they're done in black, but
the finish here has a bit of a shine to it ......
1. 事件驅動
一個事件及其回調的例子是鼠標移動。我們假設鼠標指針停在您GUI 程序的某處。如果鼠標被移到了程序的別處,一定是有什么東西引起了屏幕上指針的移動,從而表現這種位置的轉移。系統必須處理這些鼠標移動事件才能展現(并實現)鼠標在窗口上的移動。一旦您釋放了鼠標,就不再會有事件需要處 ......
二進制文件下載地址:
SinaGetBook
效果如圖:
代碼:
#!/usr/bin/env python
#coding=utf-8
#!/usr/bin/env python
#coding=utf-8
import traceback
import sys
import wx
import re
import urllib
import wx.richtext as rt
import wx.lib.buttonpanel as bp
import Casing
import Debug
def trace_back ......
總結
以上是生活随笔為你收集整理的python批量处理图片属性_python PIL 批量处理处理图片的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【测试沉思录】17. 性能测试中的系统资
- 下一篇: 计算机主页为什么打不开怎么办,为什么我的