mirror of
https://github.com/Piwigo/Piwigo.git
synced 2026-07-06 09:52:29 +02:00
-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:
@@ -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].'"';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user