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.
Image Gallery - thumbnail generation
Moderator: General Moderators
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.
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.
-
litebearer
- Forum Contributor
- Posts: 194
- Joined: Sat Mar 27, 2004 5:54 am
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.
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.
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.