mirror of
https://github.com/sjlongland/tornado-gallery.git
synced 2025-09-13 16:43:16 +10:00
photo: Define preferred image quality in metadata.
This commit is contained in:
parent
4a39507a82
commit
5de611337e
@ -12,7 +12,7 @@ except ImportError:
|
|||||||
|
|
||||||
DEFAULT_WIDTH = 720
|
DEFAULT_WIDTH = 720
|
||||||
DEFAULT_HEIGHT = 540
|
DEFAULT_HEIGHT = 540
|
||||||
DEFAULT_QUALITY = 60
|
DEFAULT_QUALITY = 60.0
|
||||||
DEFAULT_ROTATION = 0.0
|
DEFAULT_ROTATION = 0.0
|
||||||
THUMB_SIZE = 100
|
THUMB_SIZE = 100
|
||||||
|
|
||||||
@ -112,6 +112,13 @@ class Photo(object):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@property
|
||||||
|
def preferred_quality(self):
|
||||||
|
try:
|
||||||
|
return self._get_meta('.quality')
|
||||||
|
except KeyError:
|
||||||
|
return DEFAULT_QUALITY
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def prev(self):
|
def prev(self):
|
||||||
try:
|
try:
|
||||||
@ -167,8 +174,7 @@ class Photo(object):
|
|||||||
return calc_dimensions(self.width, self.height, width, height)
|
return calc_dimensions(self.width, self.height, width, height)
|
||||||
|
|
||||||
def get_rel_uri(self, width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT,
|
def get_rel_uri(self, width=DEFAULT_WIDTH, height=DEFAULT_HEIGHT,
|
||||||
rotation=DEFAULT_ROTATION, quality=DEFAULT_QUALITY,
|
rotation=DEFAULT_ROTATION, quality=None, img_format=None):
|
||||||
img_format=None):
|
|
||||||
"""
|
"""
|
||||||
Return the URI of the given photo relative to the site URI
|
Return the URI of the given photo relative to the site URI
|
||||||
"""
|
"""
|
||||||
@ -181,7 +187,7 @@ class Photo(object):
|
|||||||
uri += '@%f' % float(rotation)
|
uri += '@%f' % float(rotation)
|
||||||
|
|
||||||
# Quality
|
# Quality
|
||||||
uri += '/%f' % float(quality or 60.0)
|
uri += '/%f' % float(quality or self.preferred_quality)
|
||||||
|
|
||||||
# Format; if given
|
# Format; if given
|
||||||
if img_format is not None:
|
if img_format is not None:
|
||||||
@ -208,12 +214,12 @@ class Photo(object):
|
|||||||
|
|
||||||
# Gallery services
|
# Gallery services
|
||||||
@coroutine
|
@coroutine
|
||||||
def get_resized(self, width=None, height=None, quality=60,
|
def get_resized(self, width=None, height=None, quality=None,
|
||||||
rotation=0.0, img_format=None):
|
rotation=0.0, img_format=None):
|
||||||
result = yield self._gallery().get_resized(
|
result = yield self._gallery().get_resized(
|
||||||
photo=self.name, width=width, height=height,
|
photo=self.name, width=width, height=height,
|
||||||
quality=quality, rotation=rotation,
|
quality=quality or self.preferred_quality,
|
||||||
img_format=img_format,
|
rotation=rotation, img_format=img_format,
|
||||||
orientation=self.orientation)
|
orientation=self.orientation)
|
||||||
raise Return(result)
|
raise Return(result)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user