473,569 Members | 2,700 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

image gallery- image not displaying

116 New Member
ok i have a folder made on the server and uploaded image files to it...the link to the image file or rather the path to the image is uploaded in the database in 'image_path' , now i want that the system read the path and resize it to generate a thumbnail and display it on the browser.

but the code is showing blank

Expand|Select|Wrap|Line Numbers
  2. <?
  4. // generating a array with image paths 
  6. $query_images = "SELECT image_path FROM userfolders" ;
  7. $result_images = mysql_query($query_images);
  8. confirm_query($result_images);
  10. while ($record_images = mysql_fetch_assoc($result_images)) {
  11.           $image_list[] = $record_images['image_path'] ;
  13. ?>
  15. <?
  16. // generating a thumbnail 
  18. $thumb_height = 100;
  20. for ($i=0,$i<count($image_list),$i+)
  21. {
  23. $filename = $image_list[$i];
  24. list($width, $height) = getimagesize($filename);
  25. $ratio = ($height/$width);
  26. $newheight = $thumb_height;
  27. $newwidth = ($thumb_height/$ratio);
  29. $thumb = imagecreatetruecolor($newwidth, $newheight);
  30. $source = imagecreatefromjpeg($filename);
  32. $thumb_image = imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
  34.   // displaying thumbnail
  36. $thumbnail =  imagejpeg($thumb_image);
  38. echo $thumbnail;
  43. ?>
Plz tell me wat i m doing wrong what lines i need to add or remove.

the image path is like d:/wamp/www/images/apple.jpg
May 12 '09 #1
53 4397
code green
1,726 Recognized Expert Top Contributor
imagecopyresize d() returns a boolean, not an image resource
which imagejpeg() expects
May 12 '09 #2
116 New Member
so wat shud it be? plz tell
May 12 '09 #3
116 New Member
i even tried tht line with imagecopyresamp led() still same thing
May 12 '09 #4
code green
1,726 Recognized Expert Top Contributor
Never used this so I would have to study manual to get it right.
Have a look here http://us2.php.net/imagejpeg
May 12 '09 #5
116 New Member
i did ...the examples show similar thing ...cant understand y the images are not getting displayed
May 13 '09 #6
code green
1,726 Recognized Expert Top Contributor
The examples show the correct method, but you have not followed them.
My first post explained what you had done wrong.
I am not re-writing the code because I have never used this.
But below I am pointing out where you have gone wrong
Expand|Select|Wrap|Line Numbers
  1. //This returns a resource
  2. $thumb = imagecreatetruecolor($newwidth, $newheight); 
  3. //This also returns a resource
  4. $source = imagecreatefromjpeg($filename); 
  5. ###NOTE returns a boolean#####    
  6. $thumb_image = imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); 
  7. #######also returns a boolean and expects an image resource. 
  8. $thumbnail =  imagejpeg($thumb_image); 
  9. //You are supplying a boolean " $thumb_image "
  10. ####THEN trying to echo a boolean $thumbnail #######
  11. echo $thumbnail; 
May 13 '09 #7
116 New Member
ok so what should it be? plz tell as all examples i saw seem to use this way
May 13 '09 #8
code green
1,726 Recognized Expert Top Contributor
I get the impression you don't understand the difference
between a boolean and a resource!
I have tried to gently point you in the right direction
but you you are not interested in learning. Only in copying.
So copy this.
Expand|Select|Wrap|Line Numbers
  1. //This returns a resource 
  2. $thumb = imagecreatetruecolor($newwidth, $newheight);  
  3. //This also returns a resource ,Which one are you using????????
  4. $source = imagecreatefromjpeg($filename);     
  5. imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);   
  6. imagejpeg($thumb);  
  7. echo $thumb;  
I think you need to check how to correctly display the image, because a resource is a pointer and I doubt echo is the right thing to do here,
May 13 '09 #9
116 New Member
maybe u r not able to understand wat i m sayying... let me repeat.... i have tried all echo $thumb , echo $ source eveything.... it just returns back the link of the php file in this case i.e

May 13 '09 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

by: nick | last post by:
After spending many hours trying to find a simple looking, fast,dynamic php photo-gallery for my digital pictures, I decided to code a my own. Once installed, all you have to do is drop a new folder of images on the server. Dynamic thumbnails, slideshow are built in.
by: Daniel Kelly \(AKA Jack\) | last post by:
Hi! I'm searching for a Photo Gallery software package (like Coppermine and Gallery) that works, from the ground up, like a database-driven app. In other words, I want a gallery which entirely does away with the hierarchical structure of traditional gallery apps and allows the user to select, from a list of criteria, whatever photos he or...
by: Simone Winkler | last post by:
Hello, I don't know if my question is out of topic...so I apologize if I am. I use the coppermine picture gallery for my web (actually I want to use it but the server doesn't seem to have GD running but I will beg them to activate it). How can I actually find out if GD is installed? I tried to use phpinfo() and I searched for a GD entry,...
by: Captain Ranger McCoy | last post by:
Hello! Suppose I have ten servers at ten ips: x.x.x.1 x.x.x.2 x.x.x.3 x.x.x.4 and so on Each server hosts 100+ photo galleries, all under a single domain name,
by: Fred | last post by:
I've written a number of "image gallery" pages before, but I'm trying to do something a little different. All the images are rectangular (these are just pictures from my camera), and the thumbnail images I have are uniform in size in the sense that the longest dimension is fixed, and the shortest dimension is fixed. That is, if it's a...
by: desjardins.daniel | last post by:
Hi ! Excuse my english, i'm a french canadien... So here my message : I have put on my site a photo gallery and at the right a nav menu. This menu has a red dot visible want someone is passing over one item or clickong one item. I want to make two things in this page (the sameone http://www.danieldesjardins.com/gallery/1202015) so it...
by: Throw | last post by:
G'day everyone I'm looking for a simple photo gallery script in PHP (or Perl), but not too simple. I have tried several photo gallery scripts in either language and I have found that they are either too complex or too simple for my purpose. Most photo gallery scripts are intended primarily for sharing new photos continuously and allowing...
by: ste | last post by:
Hi there, Further to my recent posts where I've received excellent help from Rik and Jerry, I've ended up with an image gallery on my website that displays images in a table, 3 images per row. This works great and opens all images in the database when I open the url mywebsite/gallery.php, or I can choose certain images (by category) by...
by: omerbutt | last post by:
hi all i am using a slide picture gallery provided by http://smoothgallery.jondesign.net/showcase/gallery/ the gallery is working fine but only if i try to make 2 slide shows on the same page it does not load the first one in IE ,it works alright in mozilla but gives problems in IE , itried to change the names of the container and the ID of...
by: nomad | last post by:
Hello Everyone. I founded an Flash and xml photo gallery. It works but I took it to another step What I want is to have six different galleries in one Flash file. I figure out how to do that but when I click on the the galleries I can see the pervious gallery files. The gallery works like this: When you open the gallery there are links on...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.