mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Remove IM from the device driver subsystem
This commit is contained in:
parent
c36b06db9b
commit
58441b6618
@ -107,7 +107,7 @@ class ALEX(N516):
|
|||||||
|
|
||||||
def upload_cover(self, path, filename, metadata, filepath):
|
def upload_cover(self, path, filename, metadata, filepath):
|
||||||
from calibre.ebooks import calibre_cover
|
from calibre.ebooks import calibre_cover
|
||||||
from calibre.utils.magick.draw import thumbnail
|
from calibre.utils.img import scale_image
|
||||||
coverdata = getattr(metadata, 'thumbnail', None)
|
coverdata = getattr(metadata, 'thumbnail', None)
|
||||||
if coverdata and coverdata[2]:
|
if coverdata and coverdata[2]:
|
||||||
cover = coverdata[2]
|
cover = coverdata[2]
|
||||||
@ -115,8 +115,8 @@ class ALEX(N516):
|
|||||||
cover = calibre_cover(metadata.get('title', _('Unknown')),
|
cover = calibre_cover(metadata.get('title', _('Unknown')),
|
||||||
metadata.get('authors', _('Unknown')))
|
metadata.get('authors', _('Unknown')))
|
||||||
|
|
||||||
cover = thumbnail(cover, width=self.THUMBNAIL_HEIGHT,
|
cover = scale_image(cover, width=self.THUMBNAIL_HEIGHT,
|
||||||
height=self.THUMBNAIL_HEIGHT, fmt='png')[-1]
|
height=self.THUMBNAIL_HEIGHT, as_png=True)[-1]
|
||||||
|
|
||||||
cpath = self.alex_cpath(os.path.join(path, filename))
|
cpath = self.alex_cpath(os.path.join(path, filename))
|
||||||
cdir = os.path.dirname(cpath)
|
cdir = os.path.dirname(cpath)
|
||||||
|
@ -963,7 +963,7 @@ class KOBO(USBMS):
|
|||||||
debug_print('FAILED to upload cover', filepath)
|
debug_print('FAILED to upload cover', filepath)
|
||||||
|
|
||||||
def _upload_cover(self, path, filename, metadata, filepath, uploadgrayscale):
|
def _upload_cover(self, path, filename, metadata, filepath, uploadgrayscale):
|
||||||
from calibre.utils.magick.draw import save_cover_data_to
|
from calibre.utils.img import save_cover_data_to
|
||||||
if metadata.cover:
|
if metadata.cover:
|
||||||
cover = self.normalize_path(metadata.cover.replace('/', os.sep))
|
cover = self.normalize_path(metadata.cover.replace('/', os.sep))
|
||||||
|
|
||||||
@ -1016,9 +1016,7 @@ class KOBO(USBMS):
|
|||||||
|
|
||||||
# Return the data resized and in Grayscale if
|
# Return the data resized and in Grayscale if
|
||||||
# required
|
# required
|
||||||
data = save_cover_data_to(data, 'dummy.jpg',
|
data = save_cover_data_to(data, grayscale=uploadgrayscale, resize_to=resize)
|
||||||
grayscale=uploadgrayscale,
|
|
||||||
resize_to=resize, return_data=True)
|
|
||||||
|
|
||||||
with lopen(fpath, 'wb') as f:
|
with lopen(fpath, 'wb') as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
@ -2390,7 +2388,8 @@ class KOBOTOUCH(KOBO):
|
|||||||
return path
|
return path
|
||||||
|
|
||||||
def _upload_cover(self, path, filename, metadata, filepath, uploadgrayscale, keep_cover_aspect=False):
|
def _upload_cover(self, path, filename, metadata, filepath, uploadgrayscale, keep_cover_aspect=False):
|
||||||
from calibre.utils.magick.draw import save_cover_data_to, identify_data
|
from calibre.utils.img import save_cover_data_to
|
||||||
|
from calibre.utils.imghdr import identify
|
||||||
debug_print("KoboTouch:_upload_cover - filename='%s' uploadgrayscale='%s' "%(filename, uploadgrayscale))
|
debug_print("KoboTouch:_upload_cover - filename='%s' uploadgrayscale='%s' "%(filename, uploadgrayscale))
|
||||||
|
|
||||||
if metadata.cover:
|
if metadata.cover:
|
||||||
@ -2455,7 +2454,7 @@ class KOBOTOUCH(KOBO):
|
|||||||
if isFullsize:
|
if isFullsize:
|
||||||
resize = None
|
resize = None
|
||||||
else:
|
else:
|
||||||
width, height, fmt = identify_data(data)
|
fmt, width, height = identify(data)
|
||||||
cover_aspect = width / height
|
cover_aspect = width / height
|
||||||
if cover_aspect > 1:
|
if cover_aspect > 1:
|
||||||
resize = (resize[0], int(resize[0] / cover_aspect))
|
resize = (resize[0], int(resize[0] / cover_aspect))
|
||||||
@ -2464,9 +2463,7 @@ class KOBOTOUCH(KOBO):
|
|||||||
|
|
||||||
# Return the data resized and in Grayscale if
|
# Return the data resized and in Grayscale if
|
||||||
# required
|
# required
|
||||||
data = save_cover_data_to(data, 'dummy.jpg',
|
data = save_cover_data_to(data, grayscale=uploadgrayscale, resize_to=resize)
|
||||||
grayscale=uploadgrayscale,
|
|
||||||
resize_to=resize, return_data=True)
|
|
||||||
|
|
||||||
with lopen(fpath, 'wb') as f:
|
with lopen(fpath, 'wb') as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user