From ca8e0928e3d68e78b4829f2e788ddca3555c33d8 Mon Sep 17 00:00:00 2001 From: rvelices Date: Thu, 5 Dec 2013 20:53:18 +0000 Subject: fix 1 pixel rounding errors when generating multi size from another multi size git-svn-id: http://piwigo.org/svn/trunk@25793 68402e56-0260-453c-a942-63ccdbb3a9ee --- i.php | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/i.php b/i.php index 01cfc9f0a..ef267a6b4 100644 --- a/i.php +++ b/i.php @@ -284,24 +284,21 @@ function parse_request() function try_switch_source(DerivativeParams $params, $original_mtime) { global $page; - $original_size = null; - if (isset($page['original_size'])) + if (!isset($page['original_size'])) + return false; + + $original_size = $page['original_size']; + if ($page['rotation_angle']==90 || $page['rotation_angle']==270) { - $original_size = $page['original_size']; - if ($page['rotation_angle']==90 || $page['rotation_angle']==270) - { - $tmp = $original_size[0]; - $original_size[0] = $original_size[1]; - $original_size[1] = $tmp; - } + $tmp = $original_size[0]; + $original_size[0] = $original_size[1]; + $original_size[1] = $tmp; } + $dsize = $params->compute_final_size($original_size); $use_watermark = $params->use_watermark; if ($use_watermark) { - if (!isset($original_size)) - return false; // cannot really know if a watermark is required - $dsize = $params->compute_final_size($original_size); $use_watermark = $params->will_watermark($dsize); } @@ -314,6 +311,10 @@ function try_switch_source(DerivativeParams $params, $original_mtime) continue; if ($candidate->max_width() < $params->max_width() || $candidate->max_height() < $params->max_height()) continue; + $candidate_size = $candidate->compute_final_size($original_size); + if ($dsize != $params->compute_final_size($candidate_size)) + continue; + if ($params->sizing->max_crop==0) { if ($candidate->sizing->max_crop!=0) @@ -323,9 +324,6 @@ function try_switch_source(DerivativeParams $params, $original_mtime) { if ($candidate->sizing->max_crop!=0) continue; // this could be optimized - if (!isset($original_size)) - continue; - $candidate_size = $candidate->compute_final_size($original_size); if ($candidate_size[0] < $params->sizing->min_size[0] || $candidate_size[1] < $params->sizing->min_size[1] ) continue; } -- cgit v1.2.3