aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2012-07-30 19:51:44 +0000
committerrvelices <rv-github@modusoptimus.com>2012-07-30 19:51:44 +0000
commit26db3dde8fabd4b0a418f3835ad4a2064d2e8e1e (patch)
treed6be3ff50e21f7469476295454634239a59fc410
parent17999edf419c16907961c403572252a0afc3f09c (diff)
bug 2711: Watermark is sometimes applied while it should not be
git-svn-id: http://piwigo.org/svn/trunk@17229 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--i.php29
1 files changed, 25 insertions, 4 deletions
diff --git a/i.php b/i.php
index d6d58f2ed..5eb6911e3 100644
--- a/i.php
+++ b/i.php
@@ -283,12 +283,34 @@ function parse_request()
function try_switch_source(DerivativeParams $params, $original_mtime)
{
global $page;
+ $original_size = null;
+ if (isset($page['original_size']))
+ {
+ $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;
+ }
+ }
+
+ $use_watermark = $params->use_watermark;
+ if ($use_watermark)
+ {
+ if (!isset($original_size))
+ return; // cannot really know if a watermark is required
+ $dsize = $params->compute_final_size($original_size);
+ $use_watermark = $params->will_watermark($dsize);
+ ilog($use_watermark, $dsize);
+ }
+
$candidates = array();
foreach(ImageStdParams::get_defined_type_map() as $candidate)
{
if ($candidate->type == $params->type)
continue;
- if ($candidate->use_watermark != $params->use_watermark)
+ if ($candidate->use_watermark != $use_watermark)
continue;
if ($candidate->max_width() < $params->max_width() || $candidate->max_height() < $params->max_height())
continue;
@@ -301,9 +323,9 @@ function try_switch_source(DerivativeParams $params, $original_mtime)
{
if ($candidate->sizing->max_crop!=0)
continue; // this could be optimized
- if (!isset($page['original_size']))
+ if (!isset($original_size))
continue;
- $candidate_size = $candidate->compute_final_size($page['original_size']);
+ $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;
}
@@ -476,7 +498,6 @@ SELECT *
{
$page['rotation_angle'] = pwg_image::get_rotation_angle_from_code($row['rotation']);
}
-
}
if (!$row)
{