mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Remove IM from the metadata download subsystem
This commit is contained in:
parent
6f48fe28e2
commit
9de04a07bf
@ -15,7 +15,8 @@ from io import BytesIO
|
||||
from calibre.customize.ui import metadata_plugins
|
||||
from calibre.ebooks.metadata.sources.base import create_log
|
||||
from calibre.ebooks.metadata.sources.prefs import msprefs
|
||||
from calibre.utils.magick.draw import Image, save_cover_data_to
|
||||
from calibre.utils.img import save_cover_data_to
|
||||
from calibre.utils.imghdr import identify
|
||||
|
||||
class Worker(Thread):
|
||||
|
||||
@ -59,17 +60,19 @@ def is_worker_alive(workers):
|
||||
def process_result(log, result):
|
||||
plugin, data = result
|
||||
try:
|
||||
im = Image()
|
||||
im.load(data)
|
||||
if getattr(plugin, 'auto_trim_covers', False):
|
||||
from calibre.utils.magick import Image
|
||||
im = Image()
|
||||
im.load(data)
|
||||
im.trim(10)
|
||||
width, height = im.size
|
||||
fmt = im.format
|
||||
|
||||
data = im.export('JPEG')
|
||||
fmt, width, height = identify(data)
|
||||
if width < 0 or height < 0:
|
||||
raise ValueError('Could not read cover image dimensions')
|
||||
if width < 50 or height < 50:
|
||||
raise ValueError('Image too small')
|
||||
data = save_cover_data_to(im, '/cover.jpg', return_data=True)
|
||||
except:
|
||||
data = save_cover_data_to(data)
|
||||
except Exception:
|
||||
log.exception('Invalid cover from', plugin.name)
|
||||
return None
|
||||
return (plugin, width, height, fmt, data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user