mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add a tweak to change the image compression quality used by the content server when it makes thumbnails.
This commit is contained in:
parent
901fd220b3
commit
ee8c9d5c91
@ -550,3 +550,10 @@ highlight_virtual_library = 'yellow'
|
|||||||
# all available output formats to be present.
|
# all available output formats to be present.
|
||||||
restrict_output_formats = None
|
restrict_output_formats = None
|
||||||
|
|
||||||
|
#: Set the thumbnail image quality used by the content server
|
||||||
|
# The quality of a thumbnail is largely controlled by the compression quality
|
||||||
|
# used when creating it. Set this to a larger number to improve the quality.
|
||||||
|
# Note that the thumbnails get much larger with larger compression quality
|
||||||
|
# numbers.
|
||||||
|
# The value can be between 50 and 99
|
||||||
|
content_server_thumbnail_compression_quality = 70
|
@ -18,6 +18,7 @@ from calibre.utils.magick.draw import (save_cover_data_to, Image,
|
|||||||
thumbnail as generate_thumbnail)
|
thumbnail as generate_thumbnail)
|
||||||
from calibre.utils.filenames import ascii_filename
|
from calibre.utils.filenames import ascii_filename
|
||||||
from calibre.ebooks.metadata.opf2 import metadata_to_opf
|
from calibre.ebooks.metadata.opf2 import metadata_to_opf
|
||||||
|
from calibre.utils.config import tweaks
|
||||||
|
|
||||||
plugboard_content_server_value = 'content_server'
|
plugboard_content_server_value = 'content_server'
|
||||||
plugboard_content_server_formats = ['epub', 'mobi', 'azw3']
|
plugboard_content_server_formats = ['epub', 'mobi', 'azw3']
|
||||||
@ -175,8 +176,13 @@ class ContentServer(object):
|
|||||||
cherrypy.response.headers['Last-Modified'] = self.last_modified(updated)
|
cherrypy.response.headers['Last-Modified'] = self.last_modified(updated)
|
||||||
|
|
||||||
if thumbnail:
|
if thumbnail:
|
||||||
return generate_thumbnail(cover,
|
quality = tweaks['content_server_thumbnail_compression_quality']
|
||||||
width=thumb_width, height=thumb_height)[-1]
|
if quality < 50:
|
||||||
|
quality = 50
|
||||||
|
elif quality > 99:
|
||||||
|
quality = 99
|
||||||
|
return generate_thumbnail(cover, width=thumb_width,
|
||||||
|
height=thumb_height, compression_quality=quality)[-1]
|
||||||
|
|
||||||
img = Image()
|
img = Image()
|
||||||
img.load(cover)
|
img.load(cover)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user