#coding=utf-8
import sys
import os, glob
import platform
import win32file,win32con
from PIL import Image
from send2trash import send2trash
reload(sys)
sys.setdefaultencoding('utf-8')
#new_width =2048
#width =int(raw_input("the width U want:"))
#imgslist = glob.glob(path+'/*.*')
ShuiPing="水平"
ShiZhuang="矢状"
GuanZhuang="冠状"
def Py_Log(_string):
print "----"+_string.decode('utf-8')+"----"
def is_windows_system():
return 'Windows' in platform.system()
def is_hiden_file(file_Path):
if is_windows_system():
fileAttr = win32file.GetFileAttributes(file_Path)
if fileAttr & win32con.FILE_ATTRIBUTE_HIDDEN :
return True
return False
return False
def remove_hidden_file(file_path):
send2trash(file_path)
print "Delete hidden file path:"+file_path
def astrcmp(str1,str2):
return str1.lower()==str2.lower()
def resize_image(img_path):
try:
mPath, ext = os.path.splitext(img_path)
if (astrcmp(ext,".png") or astrcmp(ext,".jpg")):
img = Image.open(img_path)
(width,height) = img.size
if(width != new_width):
new_height = int(height * new_width / width)
out = img.resize((new_width,new_height),Image.ANTIALIAS)
new_file_name = '%s%s' %(mPath,ext)
out.save(new_file_name,quality=100)
Py_Log("图片尺寸修改为:"+str(new_width))