Remove option to disable webp

master
Simon Bruder 2019-12-31 14:19:56 +00:00
parent d02ae9dbb4
commit cfe77a82c1
No known key found for this signature in database
GPG Key ID: 6F03E0000CC5B62F
1 changed files with 15 additions and 17 deletions

View File

@ -51,25 +51,23 @@ def generate_thumbnail(filepath):
class CalibreDB: class CalibreDB:
def __init__(self, path='metadata.db', enable_webp=True, webp_quality=80, webp_method=0, webp_size=2048): def __init__(self, path='metadata.db', webp_quality=80, webp_method=0, webp_size=2048):
self.database_path = f'file:{path}?mode=ro' self.database_path = f'file:{path}?mode=ro'
self.webp = enable_webp # lossy: 0-100 (used as quality)
if self.webp is True: # lossless: 101-201 (101 subtracted and used as quality)
# lossy: 0-100 (used as quality) if webp_quality > 100:
# lossless: 101-201 (101 subtracted and used as quality) webp_lossless = True
if webp_quality > 100: webp_quality = webp_quality - 101
webp_lossless = True else:
webp_quality = webp_quality - 101 webp_lossless = False
else:
webp_lossless = False
self.webp_config = { self.webp_config = {
'quality': webp_quality, 'quality': webp_quality,
'method': webp_method, 'method': webp_method,
'lossless': webp_lossless, 'lossless': webp_lossless,
'size': webp_size 'size': webp_size
} }
def create_cursor(self): def create_cursor(self):
conn = sqlite3.connect(self.database_path, uri=True) conn = sqlite3.connect(self.database_path, uri=True)
@ -233,7 +231,7 @@ class CalibreDB:
page_filename = zip_info.filename page_filename = zip_info.filename
mimetype = mimetypes[os.path.splitext(page_filename)[1]] mimetype = mimetypes[os.path.splitext(page_filename)[1]]
if self.webp is True and mimetype != 'image/webp' and original is False: if original is False:
mimetype = 'image/webp' mimetype = 'image/webp'
try: try: