Karlos
06-23-2004, 08:59 AM
Hi!
I'm wondering if the talented folk who maintain this place can help me with a wee php coding task I'm looking into.
I'm presently working on upgrading the admin site (developed in house before I started) for the gallery where I now work.
The server has an image repository for artwork images. These are rather large (300DPI) which are used for printing purposes.
However, the same images are also used within the actual site front end itself - simply left up to the browser to scale down. Naturally, this ties up a lot of bandwidth and its getting slow as hell even over the LAN.
So, I want to write an automated thumbnail generation system for it. I have examined the php GD library and can see that it has what I need by way of image resampling and so on. Furthermore, our server is set up with it already, so its ready to use.
However, all the examples I looked at are geared towards simply sending the scaled thumbnail direct to the browser. This isn't quite what I need.
What I want to do is to save the thumbnail back onto the server. The idea is, we want a function eg getThumbnail($image) which works as follows
1) check if $image has a corresponding thumbnail in the thumbnails folder
2) if false, generate a thumbnail and save to the thumbnails folder
3) if true, check the date of the image and thumbnail. If the date of the image > thumbnail, generate a new thumbnail to overwrite the old one.
4) return the path to the thumbnail image
So we use getThumbnail() like this within an image tag
img src = "< ?php getThumbnail($image); ? >"
where $image is the path to the full size image.
In short, I want a server side thumbnail cache ;-)
I can figure it through except for one thing. How do I save the generated thumbnail back on the server?
I assume that fwrite($file, $thumbnail) isn't quite sufficient...
Any tips?
I'm wondering if the talented folk who maintain this place can help me with a wee php coding task I'm looking into.
I'm presently working on upgrading the admin site (developed in house before I started) for the gallery where I now work.
The server has an image repository for artwork images. These are rather large (300DPI) which are used for printing purposes.
However, the same images are also used within the actual site front end itself - simply left up to the browser to scale down. Naturally, this ties up a lot of bandwidth and its getting slow as hell even over the LAN.
So, I want to write an automated thumbnail generation system for it. I have examined the php GD library and can see that it has what I need by way of image resampling and so on. Furthermore, our server is set up with it already, so its ready to use.
However, all the examples I looked at are geared towards simply sending the scaled thumbnail direct to the browser. This isn't quite what I need.
What I want to do is to save the thumbnail back onto the server. The idea is, we want a function eg getThumbnail($image) which works as follows
1) check if $image has a corresponding thumbnail in the thumbnails folder
2) if false, generate a thumbnail and save to the thumbnails folder
3) if true, check the date of the image and thumbnail. If the date of the image > thumbnail, generate a new thumbnail to overwrite the old one.
4) return the path to the thumbnail image
So we use getThumbnail() like this within an image tag
img src = "< ?php getThumbnail($image); ? >"
where $image is the path to the full size image.
In short, I want a server side thumbnail cache ;-)
I can figure it through except for one thing. How do I save the generated thumbnail back on the server?
I assume that fwrite($file, $thumbnail) isn't quite sufficient...
Any tips?