Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Use larger thumbnails rather than smaller when method=crop #464

Merged
merged 1 commit into from
Jan 5, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions synapse/rest/media/v1/thumbnail_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ def _select_thumbnail(self, desired_width, desired_height, desired_method,

if desired_method.lower() == "crop":
info_list = []
info_list2 = []
for info in thumbnail_infos:
t_w = info["thumbnail_width"]
t_h = info["thumbnail_height"]
Expand All @@ -258,12 +259,20 @@ def _select_thumbnail(self, desired_width, desired_height, desired_method,
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 = []
Expand Down