npsari Posted March 30, 2008 Share Posted March 30, 2008 Hi, I am using this famous function to create Thumburnails for any Image on the internet Here, i use one image only... $filename = 'http://www.nature-wallpaper.info/wp-content/uploads/2007/11/desktop-wallpaper-of-korea-landscape-2.jpg'; $percent = 0.5; list($width, $height) = getimagesize($filename); $new_width = $width * $percent; $new_height = $height * $percent; $image_p = imagecreatetruecolor($new_width, $new_height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagejpeg($image_p, null, 100); The above one works fine, and the image shows However, I have many links saved in my database too So, i connect to the database, then i put the above code in a while function, the images do not show, and some crazy numbers fill up the page... $q = "SELECT * FROM image ORDER BY image_now DESC LIMIT 3 "; $res = @mysql_query($q,$con); while($r = @mysql_fetch_array($res)){ ////BIG WHILEEEEEEE $filename = $r[image_link]; $percent = 0.5; list($width, $height) = getimagesize($filename); $new_width = $width * $percent; $new_height = $height * $percent; $image_p = imagecreatetruecolor($new_width, $new_height); $image = imagecreatefromjpeg($filename); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); imagejpeg($image_p, null, 100); print"<br><br>"; } //// BIG WHILEEEEEE Any advice Link to comment https://forums.phpfreaks.com/topic/98593-creating-thumbernails-from-images/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.