Forum Moderators: coopster
here's the script i have made
list($width, $height) = getimagesize(./image/myimage.jpg);
while($width >= $maxw or $height >= $maxh) {
*$width -= 1;
*$height -= 1;
}
*= tab
$maxw and $maxh = 500
Mr. Gecko
You need to determine both, then resize. I haven't tested it but something like below should do what you need.
list($width, $height) = getimagesize(./image/myimage.jpg);
$max = 500;
if ($width>500) {
$temp = $width;
$width = $max;
$height = ($max/ $height) * $height ;
}
if ($height >$max) {
$temp = $height ;
$height = $max;
$width= ($max/ $height) * $width;
}
Most programmers frown on the use of "while" statements due to the fact that they create neverending loops that never meet the required conditions to exit. Also, the code you provided can use a lot of processor cycles if you start with a 3000x3000 image since it will have to countdown to 500. That isn't a big deal for 1 image, but may be if you get a busy site.
list($width, $height) = getimagesize($row[5]);
while($width >= 500 or $height >= 500)
{
*$width /= 1.2;
*$height /= 1.2;
}
echo "<a href=\"$PHP_SELF?do=display&img=$row[5]\" TARGET=\"_blank\">
<img src=\"$row[5]\" width=$width height=$height></a>";
* = tab
Mr. Gecko