mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
7905e70cdf
commit
4658a45c83
@ -107,7 +107,7 @@ def cover(ctx, rd, library_id, db, book_id, width=None, height=None):
|
|||||||
buf = BytesIO()
|
buf = BytesIO()
|
||||||
db.copy_cover_to(book_id, buf)
|
db.copy_cover_to(book_id, buf)
|
||||||
quality = min(99, max(50, tweaks['content_server_thumbnail_compression_quality']))
|
quality = min(99, max(50, tweaks['content_server_thumbnail_compression_quality']))
|
||||||
data = scale_image(buf.getvalue(), width=width, height=height, compression_quality=quality)
|
data = scale_image(buf.getvalue(), width=width, height=height, compression_quality=quality)[-1]
|
||||||
dest.write(data)
|
dest.write(data)
|
||||||
return create_file_copy(ctx, rd, prefix, library_id, book_id, 'jpg', mtime, copy_func)
|
return create_file_copy(ctx, rd, prefix, library_id, book_id, 'jpg', mtime, copy_func)
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ def icon(ctx, rd, which):
|
|||||||
img = image_from_data(idata)
|
img = image_from_data(idata)
|
||||||
scaled, width, height = fit_image(img.width(), img.height(), sz, sz)
|
scaled, width, height = fit_image(img.width(), img.height(), sz, sz)
|
||||||
if scaled:
|
if scaled:
|
||||||
idata = scale_image(img, width, height, as_png=True)
|
idata = scale_image(img, width, height, as_png=True)[-1]
|
||||||
try:
|
try:
|
||||||
ans = share_open(cached, 'w+b')
|
ans = share_open(cached, 'w+b')
|
||||||
except EnvironmentError:
|
except EnvironmentError:
|
||||||
|
@ -46,6 +46,6 @@ def scale_image(data, width=60, height=80, compression_quality=70, as_png=False,
|
|||||||
fmt = 'PNG' if as_png else 'JPEG'
|
fmt = 'PNG' if as_png else 'JPEG'
|
||||||
if not img.save(buf, fmt, quality=compression_quality):
|
if not img.save(buf, fmt, quality=compression_quality):
|
||||||
raise ValueError('Failed to export thumbnail image to: ' + fmt)
|
raise ValueError('Failed to export thumbnail image to: ' + fmt)
|
||||||
return ba.data()
|
return img.width(), img.height(), ba.data()
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user