-
Notifications
You must be signed in to change notification settings - Fork 35
/
1.5.py
32 lines (25 loc) · 869 Bytes
/
1.5.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import os
from PIL import Image
pathDir='F:\CloudMusic'
os.chdir(pathDir)
def get_imglist(): #获取照片名称list
img_list=[]
list_dir=os.listdir(pathDir)
for x in list_dir:
if '.jpg' in x:
img_list.append(x)
else:
print("This is not a picture: "+x)
return img_list
def modify_imgsize():
for filename in get_imglist():
img=Image.open(filename)
if max(img.size)>1136:
value=max(img.size)/1136.0
newsize =(int(img.size[0]/value),int(img.size[1]/value))
newimg = img.resize(newsize,Image.ANTIALIAS) #修改大小
newimg.save('new_'+filename)
else:
print("This picture is availabe:"+filename)
if __name__ == '__main__':
modify_imgsize()