-mulitisize added DerivativeImage->get_scaled_size method

git-svn-id: http://piwigo.org/svn/trunk@13252 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
rvelices
2012-02-19 03:18:44 +00:00
parent 5e70134c56
commit f718a18561
+32
View File
@@ -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].'"';
}
}
}
?>