-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathimage_handler.py
50 lines (40 loc) · 1.16 KB
/
image_handler.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from PIL import Image
def resize_image(image_size, filename):
# Resize the image with given dimensions
try:
im = Image.open(local_path)
im.thumbnail(image_size, Image.ANTIALIAS)
im.save(filename, "PNG")
except Exception, e:
print e
class MacApp(object):
image_arr = {
"-16.png": 16,
"[email protected]": 16 * 2,
"-32.png": 32,
"[email protected]": 32 * 2,
"-128.png": 128,
"[email protected]": 128 * 2,
"-256.png": 256,
"[email protected]": 256 * 2,
"-512.png": 512,
"[email protected]": 512 * 2,
}
local_path = "chat.png"
name = "icon"
def start(self):
for img in image_arr.keys():
resize_image((image_arr[img],image_arr[img]), "%s%s" % (name, img))
class AndroidApp(object):
image_arr = {
"mipmap-mdpi": 48,
"mipmap-hdpi": 72,
"mipmap-xhdpi": 96,
"mipmap-xxhdpi": 144,
"mipmap-xxxhdpi": 192,
}
local_path = "chat.png"
name = "chat.png"
def start(self):
for img in image_arr.keys():
resize_image((image_arr[img],image_arr[img]), "%s/%s" % (img, name))