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? Link to comment https://forums.phpfreaks.com/topic/19390-image-resize-function-an-implementation/ 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>"; Link to comment https://forums.phpfreaks.com/topic/19390-image-resize-function-an-implementation/#findComment-84152 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?? Link to comment https://forums.phpfreaks.com/topic/19390-image-resize-function-an-implementation/#findComment-84154 Share on other sites More sharing options...
litebearer Posted September 1, 2006 Share Posted September 1, 2006 see my modified response ABOVE Link to comment https://forums.phpfreaks.com/topic/19390-image-resize-function-an-implementation/#findComment-84155 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 Link to comment https://forums.phpfreaks.com/topic/19390-image-resize-function-an-implementation/#findComment-84164 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.