diff options
author | Erik Johnston <erik@matrix.org> | 2016-01-05 17:30:30 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2016-01-05 17:30:30 +0000 |
commit | 8737ead008d5b5ff17839b1aa0e4f0889d339770 (patch) | |
tree | 6721815e8cb63064ea91a427c9ca1296454c6c4b | |
parent | Merge pull request #461 from matrix-org/erikj/sync_leave (diff) | |
download | synapse-8737ead008d5b5ff17839b1aa0e4f0889d339770.tar.xz |
Use larger thumbnail rather than smaller.
-rw-r--r-- | synapse/rest/media/v1/thumbnail_resource.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/synapse/rest/media/v1/thumbnail_resource.py b/synapse/rest/media/v1/thumbnail_resource.py index e506dad934..8b8fba3dc7 100644 --- a/synapse/rest/media/v1/thumbnail_resource.py +++ b/synapse/rest/media/v1/thumbnail_resource.py @@ -248,6 +248,7 @@ class ThumbnailResource(BaseMediaResource): if desired_method.lower() == "crop": info_list = [] + info_list2 = [] for info in thumbnail_infos: t_w = info["thumbnail_width"] t_h = info["thumbnail_height"] @@ -258,12 +259,20 @@ class ThumbnailResource(BaseMediaResource): size_quality = abs((d_w - t_w) * (d_h - t_h)) type_quality = desired_type != info["thumbnail_type"] length_quality = info["thumbnail_length"] - info_list.append(( - aspect_quality, min_quality, size_quality, type_quality, - length_quality, info - )) + if t_w >= d_w or t_h >= d_h: + info_list.append(( + aspect_quality, min_quality, size_quality, type_quality, + length_quality, info + )) + else: + info_list2.append(( + aspect_quality, min_quality, size_quality, type_quality, + length_quality, info + )) if info_list: return min(info_list)[-1] + else: + return min(info_list2)[-1] else: info_list = [] info_list2 = [] |