I have a file field and I upload a file using PHP.
I need to re-size the image but I should get minimum height and width, which means no matter what is the size of the original image, if I re size the image the height should be greater than 180px and width should be greater than 160px. so how can I get resized image (thumbnail) with minimum height and width ?
I tried
$minImageWidth = 160;
$minImageHeight = 180;
$curWidth = 850;
$curHeight = 900;
if ($curWidth>$minImageWidth && $curHeight>$minImageHeight)
{
$ratio = $curWidth/$curHeight;
$zoom = $ratio > 1
? $minImageHeight / $curHeight
: $minImageWidth / $curWidth
;
echo $newWidth = $curWidth * $zoom;
echo '<br>';
echo $newHeight = $curHeight * $zoom;
}
but it doesnt work always (for example 300X300 gives wrong data output)