Skip to content

Commit a853f2f

Browse files
committed
Add 0005 file
1 parent 47d4623 commit a853f2f

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎Drake-Z/0005/0005.py‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
'第 0005 题:你有一个目录,装了很多照片,把它们的尺寸变成都不大于 iPhone5 分辨率(1136x640)的大小。'
5+
6+
__author__ = 'Drake-Z'
7+
8+
import os
9+
from PIL import Image
10+
11+
def thumbnail_pic(path):
12+
a = os.listdir(path)
13+
for x in a:
14+
name = os.path.join('0005', x)
15+
im = Image.open(name)
16+
im.thumbnail((1136, 640))
17+
print(im.format, im.size, im.mode)
18+
im.save(name, 'JPEG')
19+
print('Done!')
20+
21+
if __name__ == '__main__':
22+
path = '0005'
23+
thumbnail_pic(path)

0 commit comments

Comments
 (0)