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

Commit

Permalink
Merge pull request #205 from matrix-org/erikj/pick_largest_thumbnail
Browse files Browse the repository at this point in the history
Pick larger than desired thumbnail for 'crop'
  • Loading branch information
NegativeMjark committed Jul 23, 2015
2 parents 4e2e67f + 103e1c2 commit 6886bba
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion synapse/rest/media/v1/thumbnail_resource.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,12 @@ def _select_thumbnail(self, desired_width, desired_height, desired_method,
t_method = info["thumbnail_method"]
if t_method == "scale" or t_method == "crop":
aspect_quality = abs(d_w * t_h - d_h * t_w)
min_quality = 0 if d_w <= t_w and d_h <= t_h else 1
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, size_quality, type_quality,
aspect_quality, min_quality, size_quality, type_quality,
length_quality, info
))
if info_list:
Expand Down

0 comments on commit 6886bba

Please sign in to comment.