Skip to content

Commit ac71c1f

Browse files
committed
Finish 0005
1 parent d024d2f commit ac71c1f

4 files changed

Lines changed: 14 additions & 0 deletions

File tree

JiYouMCC/0005/0005-r.jpg

786 KB
Loading

JiYouMCC/0005/0005.jpg

760 KB
Loading

JiYouMCC/0005/0005.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# -*- coding: utf-8 -*-
2+
# 第 0005 题:你有一个目录,装了很多照片,把它们的尺寸变成都不大于 iPhone5 分辨率的大小。
3+
# using PIL in http://www.lfd.uci.edu/~gohlke/pythonlibs/#pillow
4+
from PIL import Image
5+
6+
7+
def change_image_size(image_path='0005.jpg', size=(1136, 640)):
8+
im = Image.open(image_path)
9+
size = (size[1], size[0]) if im.size[1] > im.size[0] else size
10+
im.thumbnail(size, Image.ANTIALIAS)
11+
im.save('result-' + image_path)
12+
13+
change_image_size('0005-r.jpg')
14+
change_image_size('0005.jpg')

JiYouMCC/0005/result-0005.jpg

76.1 KB
Loading

0 commit comments

Comments
 (0)