aboutsummaryrefslogtreecommitdiffstats
path: root/include/derivative.inc.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2012-04-14 04:52:20 +0000
committerrvelices <rv-github@modusoptimus.com>2012-04-14 04:52:20 +0000
commit1b54eb8e9ca1d5ac7d2fc28b37c39bf369bd0729 (patch)
tree2c61d1f9b020f2e7db58ed20a28dcce648cba570 /include/derivative.inc.php
parent10bf036231fb219ecb4cc8b6121cfec196da7eef (diff)
bug 2615 php notice in calendar amd web service
multisize improve handling of cases where the original is smaller than a requested derivative, but rotation/watermarking is required git-svn-id: http://piwigo.org/svn/trunk@14143 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include/derivative.inc.php')
-rw-r--r--include/derivative.inc.php32
1 files changed, 27 insertions, 5 deletions
diff --git a/include/derivative.inc.php b/include/derivative.inc.php
index ca840a4d9..f565364f3 100644
--- a/include/derivative.inc.php
+++ b/include/derivative.inc.php
@@ -26,6 +26,7 @@ final class SrcImage
public $id;
public $rel_path;
+ public $rotation = 0;
private $size=null;
private $flags=0;
@@ -58,9 +59,10 @@ final class SrcImage
$width = $infos['width'];
$height = $infos['height'];
+ $this->rotation = intval($infos['rotation']) % 4;
// 1 or 5 => 90 clockwise
// 3 or 7 => 270 clockwise
- if ($infos['rotation'] % 2 != 0)
+ if ($this->rotation % 2)
{
$width = $infos['height'];
$height = $infos['width'];
@@ -173,10 +175,30 @@ final class DerivativeImage
{
if ( $src->has_size() && $params->is_identity( $src->get_size() ) )
{
- // todo - what if we have a watermark maybe return a smaller size?
- $params = null;
- $rel_path = $rel_url = $src->rel_path;
- return;
+ if (!$params->use_watermark && !$src->rotation)
+ {
+ $params = null;
+ $rel_path = $rel_url = $src->rel_path;
+ return;
+ }
+ $defined_types = array_keys(ImageStdParams::get_defined_type_map());
+ for ($i=0; $i<count($defined_types); $i++)
+ {
+ if ($defined_types[$i] == $params->type)
+ {
+ for ($i--; $i>=0; $i--)
+ {
+ $smaller = ImageStdParams::get_by_type($defined_types[$i]);
+ if ($smaller->sizing->max_crop==$params->sizing->max_crop && $smaller->is_identity( $src->get_size() ))
+ {
+ $params = $smaller;
+ self::build($src, $params, $rel_path, $rel_url, $is_cached);
+ return;
+ }
+ }
+ break;
+ }
+ }
}
$tokens=array();