Click to See Complete Forum and Search --> : images on db, thumbnals and GD library?


h4x0rmx
01-28-2006, 03:15 PM
Hello you all!
I'm working on a small site where I have some galleries. The images are stored on a database and I use something like:
<img src="view_pic.php?id=1" />
to display them. Right now I'm asking for the picture and it's own thumbnail, which can be quite a lot of work for the end-user.
I have a table for the big pics and another table for the thumbnails [easier to link each pic with it's thumbnail].
I know that the GD library is available on my host, so I'm able to generate the thumbnails on the fly.
I want some suggestions from you?
What would be better? and why?
1. Create the thumbnails at upload time and store them on the db?
2. Store just the big pictures and use gd to display the thumbs only when a user is looking at the gallery?
I'm tempted to use the first option, but what do you think?

Any suggestions will be appreciated!
Thanx!

bokeh
01-28-2006, 06:26 PM
Don't store images in the database, just store the details about them. Store the images and thumbnails in the file system and use Apache to serve them. All you need to store in the DB is:

image ID
image format
image location in file system
image width
image height
caption
thumbnail location
thumbnail format
thumb width
thumb height

Just pull the details you need to insert into the html page.

Also resize the images and build the thumbs at the time of the upload, not at run time. If you do it at upload time it only needs to be done once.

If you need a function for the thumbs I'll post something.