mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
/browse: Preserve aspect ratio when resizing category icons
This commit is contained in:
parent
36c0079061
commit
40808b4a1b
@ -12,7 +12,8 @@ from binascii import hexlify, unhexlify
|
|||||||
import cherrypy
|
import cherrypy
|
||||||
|
|
||||||
from calibre.constants import filesystem_encoding
|
from calibre.constants import filesystem_encoding
|
||||||
from calibre import isbytestring, force_unicode, prepare_string_for_xml as xml
|
from calibre import isbytestring, force_unicode, fit_image, \
|
||||||
|
prepare_string_for_xml as xml
|
||||||
from calibre.utils.ordered_dict import OrderedDict
|
from calibre.utils.ordered_dict import OrderedDict
|
||||||
from calibre.utils.filenames import ascii_filename
|
from calibre.utils.filenames import ascii_filename
|
||||||
from calibre.utils.config import prefs
|
from calibre.utils.config import prefs
|
||||||
@ -267,7 +268,10 @@ class BrowseServer(object):
|
|||||||
raise cherrypy.HTTPError(404, 'no icon named: %r'%name)
|
raise cherrypy.HTTPError(404, 'no icon named: %r'%name)
|
||||||
img = Image()
|
img = Image()
|
||||||
img.load(data)
|
img.load(data)
|
||||||
img.size = (48, 48)
|
width, height = img.size
|
||||||
|
scaled, width, height = fit_image(width, height, 48, 48)
|
||||||
|
if scaled:
|
||||||
|
img.size = (width, height)
|
||||||
cherrypy.response.headers['Content-Type'] = 'image/png'
|
cherrypy.response.headers['Content-Type'] = 'image/png'
|
||||||
cherrypy.response.headers['Last-Modified'] = self.last_modified(self.build_time)
|
cherrypy.response.headers['Last-Modified'] = self.last_modified(self.build_time)
|
||||||
|
|
||||||
@ -277,7 +281,7 @@ class BrowseServer(object):
|
|||||||
categories = self.categories_cache()
|
categories = self.categories_cache()
|
||||||
category_meta = self.db.field_metadata
|
category_meta = self.db.field_metadata
|
||||||
cats = [
|
cats = [
|
||||||
(_('Newest'), 'newest', 'blank.png'),
|
(_('Newest'), 'newest', 'forward.png'),
|
||||||
]
|
]
|
||||||
|
|
||||||
def getter(x):
|
def getter(x):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user