aboutsummaryrefslogtreecommitdiffstats
path: root/i.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2013-12-05 20:53:18 +0000
committerrvelices <rv-github@modusoptimus.com>2013-12-05 20:53:18 +0000
commitca8e0928e3d68e78b4829f2e788ddca3555c33d8 (patch)
treefb25ef08d641fbac368e030ab280926a0fcc6865 /i.php
parent989d3af76509257dec83680054824aa719871432 (diff)
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
Diffstat (limited to 'i.php')
-rw-r--r--i.php28
1 files 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;
}