I've been working on a photo album because...well because I was bored. I wrote a forum and a blog already, well kinda, once I get things like 80% done I normally lose interest, but I thought this was the next thing that would be fun to play with.
Well I spend some time yesterday doing it and got it to how I wanted it, almost. I need to add so people can upload their own images, but that will be easy, my real problem is that to increase speed and save on some processing power I save the thumbnails I generate. I name them the md5 value of the md5 value of the thumbnail script and the original image file so that if the script or image changed, it knows to create a new thumbnail.
As you may have already figured out, my problem is that the old images aren't deleted ever. I'm not really sure how I can go about clearing the unused thumbnails because I would need to know the orignal md5 information of the thumbnail.php script and the image. I think I'd be able to solve this if I used a mysql database to store the md5 information, but I was hoping that wasn't necessary.
Any ideas?
All my images are in the "test2" album. You have to click that to view it.
http://www.swigg.net:2222/photoalbum/
Clearing My Image Caches
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
why not use an md5 of the original image name, and filemtime() of the image to determine if the thumbnail needs updating? If a thumbnail exists, but no corresponding image name, delete it.
Alternately, you could store thumbnails as the exact same name in a seperate directory, or a slightly altered name in the same directory...
I believe magicrobotmonkey posted a snippet (Code Snippets) with his automatic thumbnail generation and synchronization script, you may find some inspiration from that.
Alternately, you could store thumbnails as the exact same name in a seperate directory, or a slightly altered name in the same directory...
I believe magicrobotmonkey posted a snippet (Code Snippets) with his automatic thumbnail generation and synchronization script, you may find some inspiration from that.
I'm not sure I understand. The reason I'm storing the thumbnail as the summary of the thumbnail script and the original image is so that I can easily tell if either the thumbnail script or the original image has changed, which would product a different thumbnail.feyd wrote:why not use an md5 of the original image name, and filemtime() of the image to determine if the thumbnail needs updating? If a thumbnail exists, but no corresponding image name, delete it.
Alternately, you could store thumbnails as the exact same name in a seperate directory, or a slightly altered name in the same directory...
I believe magicrobotmonkey posted a snippet (Code Snippets) with his automatic thumbnail generation and synchronization script, you may find some inspiration from that.
If the original image changes name, or is removed, wouldn't I end up with a thumbnail left over then?
Hey I think I'll be good, I never knew PHP had all of those filex functions, but if I can look at modification dates and last access times I'll be good.
I think I'll do this, but what I was most worried about was load time for pages. Is a page still considered to be loading while a script is still running even if it has received the information it needs?feyd wrote:if the thumbnail name is based off the original in some fashion, you can get a list of currently held originals, and any thumbnails you find that don't correspond to one, gets deleted.
What I mean is, could I have a script that runs on the server after my thumbnail script loads without the users browser still show that it's not finished loading a page?