Skip to content

Commit 3e8f9ac

Browse files
committed
task 0005 added
1 parent 15555d7 commit 3e8f9ac

4 files changed

Lines changed: 26 additions & 0 deletions

File tree

‎agmcs/0005/0005.py‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import os
2+
from PIL import Image
3+
4+
def resize(path):
5+
im = Image.open(path)
6+
w,h = im.size
7+
if w>640:
8+
x = w/640.0
9+
w=640
10+
h = int(h//x)
11+
if h>1136:
12+
x = h/1136.0
13+
h=1136
14+
w = int(w//x)
15+
print w,h
16+
im = im.resize((w,h),Image.ANTIALIAS)
17+
im.show()
18+
im.save(path)
19+
20+
path = 'img/'
21+
dirlist = os.listdir(path)
22+
23+
for img in dirlist:
24+
abspath = os.path.join(path,img)
25+
if os.path.isfile(abspath):
26+
resize(abspath)
563 KB
Loading

‎agmcs/0005/img/1.jpg‎

247 KB
Loading
429 KB
Loading

0 commit comments

Comments
 (0)