-
Notifications
You must be signed in to change notification settings - Fork 0
/
pic.py
37 lines (30 loc) · 837 Bytes
/
pic.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
#!/usr/bin/python
#Filename:pic.py
from PIL import Image
#import makegif
class Pic(object):
def __init__(self,path):
self.path = path
self.im = Image.open(path)
def _resize(self,im):
width = 200
ratio = float(width)/im.size[0]
height = int(im.size[1]*ratio)
re = im.resize((width,height))
#re.save(self.path)
return re
#def gif_resize(self):
# image_ = []
# self.im.seek(0)
# try:
# while 1:
# image_.append(self._resize(self.im))
# self.im.seek(self.im.tell()+1)
# except EOFError:
# pass
# makegif.writeGif(self.path,image_)
def resize(self):
re = self._resize(self.im)
a = self.path.split('/')
re.save('image/'+a[1])
return re.size[1]