Jump to content

[SOLVED] PHP and GD help please


ckrieg

Recommended Posts

Alright, I've been designing sites for about 8 years now, but I never really got too heavy into the php end of things. I have no problem doing small things like contact forms, includes etc. but that's about the extent of it.

 

I had a programmer write a database for my listings and have it setup so that I can upload the full res 3mb or 4mb picture, and then GD resizes it, and if they click the resized image they get the full thing.  The problem is, that the resized image still takes forever to load even though the image is only like 50 kb.

 

Here is the website: http://www.wolfhomes.com/listings/

 

See how long it takes for those thumbnails to show up?  Now click on a property and see how long it takes for the resized images to show up. 

 

I know it is not the server as the rest of the website does not take this long, nor do the other 70 sites that I host. 

 

Here is the uploads.php file: http://www.wolfhomes.com/listings/uploads.phps

 

Now I can't seem to see where exactly it resizes the images.  I can see it uploading, and inserting into the database, but that's about it.  Any ideas on what's causing these images to take so TERRIBLY long to load up?

 

Thanks

Link to comment
Share on other sites

Are you actually inserting the binary data into the database or just a filename reference?

 

I went through this problem about 6 months ago, at first we inserted the binary data into an actual database row and as the database got bigger, the performance started to suffer.

 

We initially decided to insert into the database because the pictures were security sensitive.

 

When your user uploads an image, it should be placed on the server and only a filename reference should be inserted to the database. For the sake of privacy,you might want to  (what we did) keep the images under the document root, and then you have to read_image() or something like that - i have a script that works, but I have to go to class now. Let me know if you want more information.

 

Curt

Link to comment
Share on other sites

The problem is that the pictures are being resized every time they are loaded. You need to resize them once, then save the resized ones. These thumbnails are only 10kb, and should not take your server this long to send.

 

Anything with images is going to take a lot of CPU power to do, and should be cached/saved when possible.

Link to comment
Share on other sites

Hypnos is right.

 

Dealing with images can be a easy or hard problem.

Look like your programmer choose the easy way out.

 

The way your page work, everytime the page is requested, the php read the 4MB image, create a thumbnail, and output to browser.  That's wasting both time and cpu resource.

 

The better way is a creating a caching mechanism.  Once the image uploaded successfully, create the thumbnail in a separate folder.  When loading a page, read the thumbnail in the thumbnail folder and display.

 

 

Link to comment
Share on other sites

Alright, yes, that makes perfect sense.

 

Now how would I (or someone) do such a thing?  Any direction you could provide would be much appreciated.  is this something complicated to do?  Could I post this up in the Freelance section for like $20?

Link to comment
Share on other sites

You should let an experience programmer to do this.  Preferable one with GD skill.  It will be a little complicated.  Several files will be changed (depend) but not a lot of work.  I think this is about 3 hours work (may vary depend on structure of your site). $20 x 3 hours is about $60 is reasonable.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.