aboutsummaryrefslogtreecommitdiffstats
path: root/i.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2012-07-30 20:03:14 +0000
committerrvelices <rv-github@modusoptimus.com>2012-07-30 20:03:14 +0000
commita7895bf67b2596ddef101bf7b11ab9b53ab32b9e (patch)
treecfafb9ed6ae60223c8ccdc1f350629301d6daac7 /i.php
parentc1e3f628554ade71740cdc3a36a62def752d8f5e (diff)
merge -r17229-17230 from trunk to branch 2.4
bug 2712: Custom sized derivatives are never sharpened bug 2711: Watermark is sometimes applied while it should not be git-svn-id: http://piwigo.org/svn/branches/2.4@17231 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--i.php41
1 files changed, 36 insertions, 5 deletions
diff --git a/i.php b/i.php
index d6d58f2ed..2410e356c 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 false; // 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;
}
@@ -324,7 +346,9 @@ function try_switch_source(DerivativeParams $params, $original_mtime)
$page['src_path'] = $candidate_path;
$page['src_url'] = $page['root_path'] . substr($candidate_path, strlen(PHPWG_ROOT_PATH));
$page['rotation_angle'] = 0;
+ return true;
}
+ return false;
}
function send_derivative($expires)
@@ -476,7 +500,6 @@ SELECT *
{
$page['rotation_angle'] = pwg_image::get_rotation_angle_from_code($row['rotation']);
}
-
}
if (!$row)
{
@@ -494,7 +517,15 @@ else
}
mysql_close($pwg_db_link);
-try_switch_source($params, $src_mtime);
+if (!try_switch_source($params, $src_mtime) && $params->type==IMG_CUSTOM)
+{
+ $sharpen = 0;
+ foreach (ImageStdParams::get_defined_type_map() as $std_params)
+ {
+ $sharpen += $std_params->sharpen;
+ }
+ $params->sharpen = round($sharpen / count(ImageStdParams::get_defined_type_map()) );
+}
if (!mkgetdir(dirname($page['derivative_path'])))
{