all images same size
Posted: Tue Jul 12, 2005 8:08 am
ok this is kinda theoretical im just not sure how to go about it. i have a site where you can upload pictures but somtimes people want to upload huge pictures (fine) but i dont want to resize them and save them i will just resize them with the img height width way. i made a nice way of resizing them based on their size but i want to make all the pictures to the same size but i dont want to distort pictures with it. heres the code i have now
Code: Select all
while (false !== ($file = readdir($dir)))
{
if ($file != '.' && $file != '..')
{
$for_half = '750';
$for_fourth = '1000';
$for_small = '1500';
$half = '0.5';
$fourth = '0.25';
$small = '0.15';
list($width, $height) = getimagesize("./users/".$_SESSION['username']."/".$file);
if ($width > $for_small || $height > $for_small)
{
$newwidth = $width * $small;
$newheight = $height * $small;
}
else if ($width > $for_fourth || $height > $for_fourth)
{
$newwidth = $width * $fourth;
$newheight = $height * $fourth;
}
else if ($width > $for_half || $height > $for_half)
{
$newwidth = $width * $half;
$newheight = $height * $half;
}
echo $height.' '.$width;
echo '<img src="./users/'.$_SESSION['username'].'/'.$file.'" height="'.$newwidth.'" width="'.$newheight.'">';
}
}