FIX: IIIF API Handler - add check image width height [t24086]

git-svn-id: http://svn.resourcespace.com/svn/rs/trunk@16534 c08608d7-6e46-0410-86ca-f2a6f1370df5
This commit is contained in:
tgray 2020-11-27 09:46:51 +00:00
parent 6cfd0ef416
commit 973f8a5ccf
1 changed files with 18 additions and 15 deletions

View File

@ -84,23 +84,26 @@ else
// Get all available sizes
$sizes = get_image_sizes($resourceid,true,"jpg",false);
$availsizes = array();
foreach($sizes as $size)
if ($imageWidth > 0 && $imageHeight > 0)
{
// Compute actual pixel size - use same calculations as when generating previews
if ($portrait)
foreach($sizes as $size)
{
// portrait or square
$preheight = $size['height'];
$prewidth = round(($imageWidth * $preheight + $imageHeight - 1) / $imageHeight);
}
else
{
$prewidth = $size['width'];
$preheight = round(($imageHeight * $prewidth + $imageWidth - 1) / $imageWidth);
}
if($prewidth > 0 && $preheight > 0 && $prewidth <= $iiif_max_width && $preheight <= $iiif_max_height)
{
$availsizes[] = array("id"=>$size['id'],"width" => $prewidth, "height" => $preheight);
// Compute actual pixel size - use same calculations as when generating previews
if ($portrait)
{
// portrait or square
$preheight = $size['height'];
$prewidth = round(($imageWidth * $preheight + $imageHeight - 1) / $imageHeight);
}
else
{
$prewidth = $size['width'];
$preheight = round(($imageHeight * $prewidth + $imageWidth - 1) / $imageWidth);
}
if($prewidth > 0 && $preheight > 0 && $prewidth <= $iiif_max_width && $preheight <= $iiif_max_height)
{
$availsizes[] = array("id"=>$size['id'],"width" => $prewidth, "height" => $preheight);
}
}
}