-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathimage.py
30 lines (27 loc) · 1.09 KB
/
image.py
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
from PIL import Image as pil
class Image:
def resize(self, image, tileWidth):
return image.resize((int(0.8*tileWidth),int(0.8*tileWidth)))
def __init__(self, tileWidth):
try:
self.flagImageUnResized = pil.open("images/flag.png")
self.flagImage=self.resize(self.flagImageUnResized, tileWidth)
except:
print("Flag icon file not found.")
self.flagImage=None
try:
self.mineImage = pil.open("images/mine.png")
self.mineImage=self.resize(self.mineImage, tileWidth)
except:
print("Mine icon file not found.")
self.mineImage=None
try:
self.flagWrongImage = pil.open("images/flag_wrong.png")
self.flagWrongImage=self.resize(self.flagWrongImage, tileWidth)
except:
print("Flag_Wrong icon file not found.")
self.flagWrongImage=None
if __name__ == "__main__":
image=Image(512)
image.flagImage.show()
image.mineImage.show()