-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImage.py
More file actions
44 lines (35 loc) · 892 Bytes
/
Copy pathImage.py
File metadata and controls
44 lines (35 loc) · 892 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
40
41
42
43
44
import PIL
from PIL import Image
class Img(object):
"""
"""
def __init__(self, width, height, color=(0,0,0)):
"""
:param width:
:param height:
:param color:
"""
self.width = width
self.height = height
self.img = Image.new("RGB", (self.width, self.height), color)
def draw(self, x, y, color):
"""
:param x:
:param y:
:param color:
:return:
"""
self.img.putpixel((x, y), color)
def save(self, filename):
"""
:param filename:
:return:
"""
self.img.transpose(PIL.Image.FLIP_TOP_BOTTOM)
self.img.save(filename, "PNG")
def show(self):
"""
:return:
"""
self.img.transpose(PIL.Image.FLIP_TOP_BOTTOM)
self.img.show()