Hello, I use the code below to get the web paths and the names of images from a database, then I use it to get the widths and heights of those images, then I use it to display those images:
function size($num){
$num = $num;
if($num > 150){
$amt1 = 150 / $num;
$amt2 = $num * round($amt1, 2);
$amt = $amt2;
}else{
$amt = $num;
}
return $amt;
}
$this_webPath = $row['webPath'];
$this_pic = $row['pic'];
list($width, $height, $type, $attr) = getimagesize("images/".$this_pic);
$width = size($width);
$height = size($height);
echo "<a href='$this_webPath'><img src=$webPath/$this_pic' width='$width' height='$height' border='0'/></a>";
My question is this, after I get these images, is there any type of coding I can use to conform its ratio to a standard size? What I mean is this, the width of any image should be 150px or less, the height of any image should be 150px or less. If the width or height or both is greater, the image should be reduced
I came up with the following code and tried it on an image that is 1024px wide X 768 px height, but it did not work, the ratio of the width and height of the image is still wrong Can you please help me correct this code? Here is the code:
function size($num){
$num = $num;
if($num > 150){
$amt1 = 150 / $num;
$amt2 = $num * round($amt1, 2);
$amt = $amt2;
}else{
$amt = $num;
}
return $amt;
}
Please help, please?
Thanks!