mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -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.customize.ui import metadata_plugins
|
||||||
from calibre.ebooks.metadata.sources.base import create_log
|
from calibre.ebooks.metadata.sources.base import create_log
|
||||||
from calibre.ebooks.metadata.sources.prefs import msprefs
|
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):
|
class Worker(Thread):
|
||||||
|
|
||||||
@ -59,17 +60,19 @@ def is_worker_alive(workers):
|
|||||||
def process_result(log, result):
|
def process_result(log, result):
|
||||||
plugin, data = result
|
plugin, data = result
|
||||||
try:
|
try:
|
||||||
im = Image()
|
|
||||||
im.load(data)
|
|
||||||
if getattr(plugin, 'auto_trim_covers', False):
|
if getattr(plugin, 'auto_trim_covers', False):
|
||||||
|
from calibre.utils.magick import Image
|
||||||
|
im = Image()
|
||||||
|
im.load(data)
|
||||||
im.trim(10)
|
im.trim(10)
|
||||||
width, height = im.size
|
data = im.export('JPEG')
|
||||||
fmt = im.format
|
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:
|
if width < 50 or height < 50:
|
||||||
raise ValueError('Image too small')
|
raise ValueError('Image too small')
|
||||||
data = save_cover_data_to(im, '/cover.jpg', return_data=True)
|
data = save_cover_data_to(data)
|
||||||
except:
|
except Exception:
|
||||||
log.exception('Invalid cover from', plugin.name)
|
log.exception('Invalid cover from', plugin.name)
|
||||||
return None
|
return None
|
||||||
return (plugin, width, height, fmt, data)
|
return (plugin, width, height, fmt, data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user