Image Gallery - thumbnail generation

Need help with Photoshop, the GIMP, Illustrator, or others? Want to show off your work? Looking for advice on your newest Flash stuff?

Moderator: General Moderators

Post Reply
bradles
Forum Commoner
Posts: 89
Joined: Wed Jun 30, 2004 10:40 pm

Image Gallery - thumbnail generation

Post by bradles »

I am going to be putting together an image gallery for each of my clients in php. I am thinking I will store the large images in a folder called IMAGES and the thumbnails in a folder called THUMBNAILS. Then the php will load up the thumbnails on left of screen and when a thumbnail is clicked the larger image will show on right of screen.

Will this be hard to code in terms of errors? - example, user clicks image #1 thumbnail and image #3 shows on right of screen.

Or is there a way that you can have thumbnails generated as required by the user. Example, php makes thumbnails of larger images and then displays them.

Would appreciate any thoughts or experience in this matter.
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

i always choose to make the thumbs when the image is uploaded, it saves time and resources beacuse it wont be done over and over agian.

so, all you need to do is,

- allow upload of image
- workout a random string (for the filename)
- upload the image to IMAGES
- make a thumb of it with the same name, copy it to THUMBS

then just show images from THUMBS, but link to images in IMAGES folder, you can find sample code for all the above points in this forum by searching, good luck.
bradles
Forum Commoner
Posts: 89
Joined: Wed Jun 30, 2004 10:40 pm

Post by bradles »

excellent. That's how I was thinking of doing it. It's good to know I'm barking up the right tree.

Thanks qad.
litebearer
Forum Contributor
Posts: 194
Joined: Sat Mar 27, 2004 5:54 am

Post by litebearer »

Thought this might interest you

http://nstoia.com/testpg01/

Lite...
slobeck
Forum Newbie
Posts: 2
Joined: Sun Sep 19, 2004 11:52 am
Location: Marin Co. Ca

Post by slobeck »

It's been a while, but here's how I did this. I too used "pictures" and "thumbnails" folders.

I drop a .jpg (or whatever) into the 'pictures" folder.

When someone visits the gallery, php reads the directory of the "pictures" folder and COMPARES it to the directory of the "thumbnails" folder.

If there is a picture without a correspoding thumbnail, GD takes the picture, copies and resizes the copy and deposits it into the "thumbnails" folder. That way the thumbnails are only generated ONCE and subsequent visits will not have to wait.

The same basic process works the other way around. ie: removing images from the gallery. Once per session I have the folders compared and if there is a thumbnail without it's larger sibling, it removes the thumbnail.

Hope that helps...

One of my current projects is to use this technique again but with the benefits of the new object model. If I get it going quickly enough, I'll append this post with a link.

As far as difficulty goes, I'd say it's of moderate difficulty. You'll need php's file system functions, and GD to do this right. Feel free to email me with questions. If I can help, I'd be glad to.
mikejolly
Forum Newbie
Posts: 1
Joined: Fri Apr 27, 2007 3:23 am

Post by mikejolly »

I think there is an option for this on http://www.irisize.com that might be helpfull .
Last edited by mikejolly on Thu May 03, 2007 6:56 am, edited 1 time in total.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

The last post was over 2 years ago - I think the user's moved on. Please refrain from bumping ancient (relatively speaking) threads.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply