Goetz Lohmann schrieb: > Geckodeep schrieb: > >>Hi there I have this problem wondering how to define the size of my images. >>I have this page that has 9 images coming from the database. These images >>are uploaded into a folder and the names are referenced in the DB. >>I pull the image through these tags >><?php print "<img alt='$title' border=0 width= '103' heigth = '70' >>src=\"$folder/$image1\">" ?> >>and it's ok if the images are rectangular with size 104 x 70,but how will I >>reduce the size of the image having the opposite size 70 x 104 rectangular >>but shorter in length. >> >>Hard coding the size is not the solution for me as these images are coming >>straight from the DB with their actual size. >> >>Having decided the sizes to be either 104 x 70 or 70 x 104, now the trouble >>is how to assignee these values dynamically judging the format of the image. >> >>I've seen different script in resizing the images on the fly but couldn't >>adapt to my needs, as I've 9 image variables ($image1, $image2,..)already >>assigned and I am looking for scripts or solutions in resizing the images on >>the fly by assigning my 9image variables to the resize function. >> >>Thanks once again. > > > its just mathematic ;-)
UPS ... sorry ... if using $height/$h and $width/$w I should it in the whole script ... <?php // get size // $w = 640; // width $h = 480; // height $maxsize = 150; // maximum size in one direction // prevent division by zero if (($h ==0) || ($w==0)) exit; // get new size according to max size if ($h>$w) { $new_h = $maxsize; // new height $new_w = (int) (($maxsize * $w) / $h); // casting to int ! } else { $new_w = $maxsize; // new width $new_h = (int) (($maxsize * $h) / $w); // casting to int ! } // resize image echo "newsize: $new_w x $new_h"; // new thumbnail is in $thumb ?> now that should do ! ;-) -- @ Goetz Lohmann, Germany | Web-Developer & Sys-Admin \/ ------------------------------------------------------ () He's the fellow that people wonder what he does and || why the company needs him, until he goes on vacation. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php