Add a tweak to change the image compression quality used by the content server when it makes thumbnails.

This commit is contained in:
Charles Haley 2013-09-27 17:05:33 +02:00
parent 901fd220b3
commit ee8c9d5c91
2 changed files with 15 additions and 2 deletions

View File

@ -550,3 +550,10 @@ highlight_virtual_library = 'yellow'
# all available output formats to be present.
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

View File

@ -18,6 +18,7 @@ from calibre.utils.magick.draw import (save_cover_data_to, Image,
thumbnail as generate_thumbnail)
from calibre.utils.filenames import ascii_filename
from calibre.ebooks.metadata.opf2 import metadata_to_opf
from calibre.utils.config import tweaks
plugboard_content_server_value = 'content_server'
plugboard_content_server_formats = ['epub', 'mobi', 'azw3']
@ -175,8 +176,13 @@ class ContentServer(object):
cherrypy.response.headers['Last-Modified'] = self.last_modified(updated)
if thumbnail:
return generate_thumbnail(cover,
width=thumb_width, height=thumb_height)[-1]
quality = tweaks['content_server_thumbnail_compression_quality']
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.load(cover)