jpratt Posted September 1, 2006 Share Posted September 1, 2006 i have a function that resizes an image when it loads the page according to its ration(so it doesnt look all funny) I am having problems implementing this function and getting it to display, check out the function and where i am trying to use it. Please help.where it is implemented...[code]echo "<TABLE border=0 id='gallery'>";while (list($thumb) = mysql_fetch_row($res)) { $mysock = getimagesize($thumb); $resizethumb = imageResize($mysock[0], $mysock[1], 150); if ($count % NUMCOLS == 0) echo "<TR>\n"; # new row echo "<td><img src='$resizethumb'></td><br>\n"; $count++; if ($count % NUMCOLS == 0) echo "</TR>\n"; # end row}if ($count % NUMCOLS != 0) { while ($count++ % NUMCOLS) echo "<td> </td>"; echo "</TR>\n";}echo "</TABLE>";[/code]the function...[code]<?php function imageResize($width, $height, $target) { if ($width > $height) { $percentage = ($target / $width); } else { $percentage = ($target / $height); } //gets the new value and applies the percentage, then rounds the value $width = round($width * $percentage); $height = round($height * $percentage); return "width=\"$width\" height=\"$height\""; } ?>[/code] right now i am just getting the little X boxs where images are sapose to be. any ideas? Quote Link to comment Share on other sites More sharing options...
litebearer Posted September 1, 2006 Share Posted September 1, 2006 This line is NOT telling what image - it simply is giving the dimensions.[code]echo "<td><img src='$resizethumb'></td><br>\n";[/code]tryecho "<td><img src=" . $whatevertheimagenameandpathare . $resizethumb ."></td>"; Quote Link to comment Share on other sites More sharing options...
jpratt Posted September 1, 2006 Author Share Posted September 1, 2006 so how do i tell it both the image and the hieght and width?? Quote Link to comment Share on other sites More sharing options...
litebearer Posted September 1, 2006 Share Posted September 1, 2006 see my modified response ABOVE Quote Link to comment Share on other sites More sharing options...
jpratt Posted September 1, 2006 Author Share Posted September 1, 2006 thanks, got it, my image was there just needed to tweek that line a little. the image variable is $image in the example Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.