update json
Before Width: | Height: | Size: 134 KiB After Width: | Height: | Size: 134 KiB |
BIN
manifest/jpeg/015a11a57f73ec3887bdf77f8f8a02f9.th.jpeg
Normal file
After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 169 KiB After Width: | Height: | Size: 169 KiB |
BIN
manifest/jpeg/070a095cf72042b8eebe78124f8225bb.th.jpeg
Normal file
After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 892 KiB After Width: | Height: | Size: 895 KiB |
BIN
manifest/jpeg/fb7ab0a3878d821fffa8c1f06ec5e8d2.th.jpeg
Normal file
After Width: | Height: | Size: 28 KiB |
Before Width: | Height: | Size: 312 KiB After Width: | Height: | Size: 312 KiB |
BIN
manifest/jpeg/fbefd92059006090601cb6dafdce544c.th.jpeg
Normal file
After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 116 KiB After Width: | Height: | Size: 116 KiB |
BIN
manifest/jpeg/fcff045964e4ac6fffd84a8192a0a393.th.jpeg
Normal file
After Width: | Height: | Size: 16 KiB |
@ -1 +1 @@
|
||||
{"070a095cf72042b8eebe78124f8225bb": {"source": "AK-01.jpg", "jpeg": "jpeg/070a095cf72042b8eebe78124f8225bb.jpeg", "webp": "webp/070a095cf72042b8eebe78124f8225bb.webp"}, "015a11a57f73ec3887bdf77f8f8a02f9": {"source": "AK-02.jpg", "jpeg": "jpeg/015a11a57f73ec3887bdf77f8f8a02f9.jpeg", "webp": "webp/015a11a57f73ec3887bdf77f8f8a02f9.webp"}, "fb7ab0a3878d821fffa8c1f06ec5e8d2": {"source": "AK-03.jpg", "jpeg": "jpeg/fb7ab0a3878d821fffa8c1f06ec5e8d2.jpeg", "webp": "webp/fb7ab0a3878d821fffa8c1f06ec5e8d2.webp"}, "fbefd92059006090601cb6dafdce544c": {"source": "AK-04.jpg", "jpeg": "jpeg/fbefd92059006090601cb6dafdce544c.jpeg", "webp": "webp/fbefd92059006090601cb6dafdce544c.webp"}, "fcff045964e4ac6fffd84a8192a0a393": {"source": "AK-05.jpg", "jpeg": "jpeg/fcff045964e4ac6fffd84a8192a0a393.jpeg", "webp": "webp/fcff045964e4ac6fffd84a8192a0a393.webp"}}
|
||||
{"fbefd92059006090601cb6dafdce544c": {"source": "AK-04.jpg", "jpeg": ["jpeg/fbefd92059006090601cb6dafdce544c.jpeg", "jpeg/fbefd92059006090601cb6dafdce544c.th.jpeg"], "webp": ["webp/fbefd92059006090601cb6dafdce544c.webp", "webp/fbefd92059006090601cb6dafdce544c.th.webp"]}, "fcff045964e4ac6fffd84a8192a0a393": {"source": "AK-05.jpg", "jpeg": ["jpeg/fcff045964e4ac6fffd84a8192a0a393.jpeg", "jpeg/fcff045964e4ac6fffd84a8192a0a393.th.jpeg"], "webp": ["webp/fcff045964e4ac6fffd84a8192a0a393.webp", "webp/fcff045964e4ac6fffd84a8192a0a393.th.webp"]}, "015a11a57f73ec3887bdf77f8f8a02f9": {"source": "AK-02.jpg", "jpeg": ["jpeg/015a11a57f73ec3887bdf77f8f8a02f9.jpeg", "jpeg/015a11a57f73ec3887bdf77f8f8a02f9.th.jpeg"], "webp": ["webp/015a11a57f73ec3887bdf77f8f8a02f9.webp", "webp/015a11a57f73ec3887bdf77f8f8a02f9.th.webp"]}, "fb7ab0a3878d821fffa8c1f06ec5e8d2": {"source": "AK-03.jpg", "jpeg": ["jpeg/fb7ab0a3878d821fffa8c1f06ec5e8d2.jpeg", "jpeg/fb7ab0a3878d821fffa8c1f06ec5e8d2.th.jpeg"], "webp": ["webp/fb7ab0a3878d821fffa8c1f06ec5e8d2.webp", "webp/fb7ab0a3878d821fffa8c1f06ec5e8d2.th.webp"]}, "070a095cf72042b8eebe78124f8225bb": {"source": "AK-01.jpg", "jpeg": ["jpeg/070a095cf72042b8eebe78124f8225bb.jpeg", "jpeg/070a095cf72042b8eebe78124f8225bb.th.jpeg"], "webp": ["webp/070a095cf72042b8eebe78124f8225bb.webp", "webp/070a095cf72042b8eebe78124f8225bb.th.webp"]}}
|
@ -1,4 +1,4 @@
|
||||
#coding=utf-8
|
||||
# coding=utf-8
|
||||
'''
|
||||
Created on Apr 23, 2018
|
||||
Desc: Webp convertor
|
||||
@ -23,23 +23,32 @@ class Single(object):
|
||||
self.hash = hasher.hexdigest()
|
||||
self.jpeg = 'jpeg/' + self.hash + '.jpeg'
|
||||
self.webp = 'webp/' + self.hash + '.webp'
|
||||
self.th_jpeg = 'jpeg/' + self.hash + '.th.jpeg'
|
||||
self.th_webp = 'webp/' + self.hash + '.th.webp'
|
||||
|
||||
def optimize(self):
|
||||
im = Image.open('gallary/' + self.file).convert('RGB')
|
||||
im.save(self.jpeg, 'JPEG') # todo: TinyPNG API
|
||||
im.save(self.webp, 'WEBP')
|
||||
|
||||
def thumbnail(self):
|
||||
im = Image.open('gallary/' + self.file).convert('RGB')
|
||||
im.thumbnail((450, 300))
|
||||
im.save(self.th_jpeg, 'JPEG') # todo: TinyPNG API
|
||||
im.save(self.th_webp, 'WEBP')
|
||||
|
||||
def manifest(self):
|
||||
self.mani[self.hash] = {
|
||||
'source': self.file,
|
||||
'jpeg': 'jpeg/' + self.hash + '.jpeg',
|
||||
'webp': 'webp/' + self.hash + '.webp'
|
||||
'jpeg': ['jpeg/' + self.hash + '.jpeg', 'jpeg/' + self.hash + '.th.jpeg'],
|
||||
'webp': ['webp/' + self.hash + '.webp', 'webp/' + self.hash + '.th.webp']
|
||||
}
|
||||
|
||||
def main(self):
|
||||
self.hash()
|
||||
# if os.path.exists(self.jpeg) and os.path.exists(self.webp):
|
||||
self.optimize()
|
||||
self.thumbnail()
|
||||
self.manifest()
|
||||
return self.mani
|
||||
|
||||
|
BIN
manifest/webp/015a11a57f73ec3887bdf77f8f8a02f9.th.webp
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
manifest/webp/070a095cf72042b8eebe78124f8225bb.th.webp
Normal file
After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 131 KiB After Width: | Height: | Size: 131 KiB |
BIN
manifest/webp/fb7ab0a3878d821fffa8c1f06ec5e8d2.th.webp
Normal file
After Width: | Height: | Size: 25 KiB |
Before Width: | Height: | Size: 660 KiB After Width: | Height: | Size: 661 KiB |
BIN
manifest/webp/fbefd92059006090601cb6dafdce544c.th.webp
Normal file
After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 237 KiB After Width: | Height: | Size: 238 KiB |
BIN
manifest/webp/fcff045964e4ac6fffd84a8192a0a393.th.webp
Normal file
After Width: | Height: | Size: 11 KiB |