CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
jackfrued

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: jackfrued/Python-100-Days
Path: blob/master/Day01-15/code/Day15/pillow1.py
Views: 729
1
"""
2
使用pillow操作图像
3
4
Version: 0.1
5
Author: 骆昊
6
Date: 2018-03-26
7
"""
8
from PIL import Image
9
10
img = Image.open('./res/guido.jpg')
11
print(img.size)
12
print(img.format)
13
print(img.format_description)
14
img.save('./res/guido.png')
15
16
img2 = Image.open('./res/guido.png')
17
img3 = img2.crop((335, 435, 430, 615))
18
for x in range(4):
19
for y in range(5):
20
img2.paste(img3, (95 * y , 180 * x))
21
img2.resize((img.size[0] // 2, img.size[1] // 2))
22
img2.rotate(90)
23
img2.save('./res/guido2.png')
24
25