From af50aef4b814d1e1139fb272cd9202d74583a139 Mon Sep 17 00:00:00 2001 From: Peter Molnar Date: Wed, 13 Jun 2018 08:27:23 +0000 Subject: [PATCH] panoramas are special, so treat them accordingly --- nasg.py | 10 +++++++++- templates/MagicPHP.html | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/nasg.py b/nasg.py index 0ed759a..ee08975 100644 --- a/nasg.py +++ b/nasg.py @@ -1167,7 +1167,15 @@ class WebImage(object): def _intermediate_dimension(self, size, width, height, crop=False): """ Calculate intermediate resize dimension and return a tuple of width, height """ size = int(size) - if (width > height and not crop) \ + if (width > height*3): + size = int(size * 0.6) + # panorama + if (height <= size): + h = height + else: + h = size + w = int(float(h / height) * width) + elif (width > height and not crop) \ or (width < height and crop): w = size h = int(float(size / width) * height) diff --git a/templates/MagicPHP.html b/templates/MagicPHP.html index 3d98f2a..b9672f9 100644 --- a/templates/MagicPHP.html +++ b/templates/MagicPHP.html @@ -58,13 +58,13 @@ function maybe_redirect($uri) { $redirects = array( {% for (from, to) in redirects %} "{{ from }}" => "{{ to }}", -{% endfor %} +{%- endfor %} ); $gone = array( {% for gone in gones %} "{{ gone }}" => true, -{% endfor %} +{%- endfor %} ); $uri = filter_var($_SERVER['REQUEST_URI'], FILTER_SANITIZE_URL);