diff options
author | rvelices <rv-github@modusoptimus.com> | 2012-02-19 03:18:44 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2012-02-19 03:18:44 +0000 |
commit | f718a18561915a6d547e96a7aef8f75283981853 (patch) | |
tree | 54854f9ba7472b432f8a6d96618b8487114a889e /include/derivative.inc.php | |
parent | 5e70134c56da49fdb813227ac0d2b05bece01c84 (diff) |
-mulitisize added DerivativeImage->get_scaled_size method
git-svn-id: http://piwigo.org/svn/trunk@13252 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r-- | include/derivative.inc.php | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/include/derivative.inc.php b/include/derivative.inc.php index 2f2f4b3d1..844d93911 100644 --- a/include/derivative.inc.php +++ b/include/derivative.inc.php @@ -271,6 +271,38 @@ final class DerivativeImage } } + function get_scaled_size($maxw, $maxh) + { + $size = $this->get_size(); + if ($size) + { + $ratio_w = $size[0] / $maxw; + $ratio_h = $size[1] / $maxh; + if ($ratio_w>1 || $ratio_h>1) + { + if ($ratio_w > $ratio_h) + { + $size[0] = $maxw; + $size[1] = floor($size[1] / $ratio_w); + } + else + { + $size[0] = floor($size[0] / $ratio_h); + $size[1] = $maxh; + } + } + } + return $size; + } + + function get_scaled_size_htm($maxw=9999, $maxh=9999) + { + $size = $this->get_scaled_size($maxw, $maxh); + if ($size) + { + return 'width="'.$size[0].'" height="'.$size[1].'"'; + } + } } ?>
\ No newline at end of file |