-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithubtest01.py
More file actions
57 lines (32 loc) · 798 Bytes
/
githubtest01.py
File metadata and controls
57 lines (32 loc) · 798 Bytes
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
33
34
35
36
37
38
39
from PIL import Image,ImageDraw
'''
def add_num(img):
draw = ImageDraw.Draw(img)
fillcolor = '#ff0000'
width,height = img.size
draw.text((width-50,20),'99',font = None,fill = fillcolor)
img.save('result1.png','png')
img.show()
if __name__ == '__main__':
image = Image.open('test.png')
add_num(image)
'''
'''
im = Image.open('test.png')
im.rotate(45).show()
'''
def rollimg(img,delta):
image = img.copy()
xsize,ysize = image.size
delta = delta%xsize
if delta == 0:
return image
part1 = image.crop((0,0,delta,ysize))
part2 = image.crop((delta,0,xsize,ysize))
image.paste(part2,(0,0,xsize-delta,ysize))
image.paste(part1,(xsize-delta,0,xsize,ysize))
image.show()
#return image
if __name__ == '__main__':
image = Image.open('test.png')
rollimg(image,90)