As far as I can tell though, the only thing this does is figure out the correct aspect ration for the resized image and output that as HTML. This creates two problems:
The images being displayed haven’t been reduced in size so a list of “thumbnails” would take forever and a day to download. (This limitation was pointed out in the article as well.)
The image being displayed is going to be resized by the browser which generally results in jagged edges and a crap-tacular job.
Am I missing something here or does this script have some magic that I just don’t see?
In most cases, I would use ImageMagik so that I could have a regular version and a thumbnail version of each image.
http://php.net/manual/en/book.imagick.php
This will let you actually create a thumbnail size. I used it and it works well. I coded my script quite sometime ago, so I can’t easily help with the details. But, they are there. When a new picture is uploaded to my site the thumbnail is created automatically.
Hope this helps.
I’ve got a script to do the resizing. Thanks for the resource though. I guess I was just commenting on this article. I see the usefulness of the PHP function within a script that creates a resized image but just don’t see how it’s useful without saving a resized image.
It would be useful if like the author, you didn’t want
4,000 different thumbnails sitting around taking up space.
(I guess 4,000 full-size full-weight images are OK?)
Other than that, IMHO it falls into the category of “stupid PHP tricks”. Interesting exercize for a PHP newbie perhaps but not really very applicable in general.
It is not such cool, but reliable.
But it will be first in the queue to optimization once you decide to profile your site because of slowness. Too much useless memory and CPU consumption.
In the past, I’ve utilised mod_rewrite invoke the thumbnail creation process. Given /images/thumbnails/coffee-bean.jpg, if this was to result in a 404, the script would be invoked to create the thumbnail and display it.
So you would code the 404 to look for an image extension in the requested path? I don’t understand how you would distinguish between a 404 from the image path and a 404 from a truly non-existent page. Additionally, how were you passing where the image was actually located so the thumbnail could be generated?
If the script is working correctly, the images are cached so as not to suck up all the memory and CPU. Not using any more resources than resizing them on upload.
If you can’t find the .htaccess don’t worry. I think I understand where you’re coming from. That seems a bit overly complicated for this application but I like the idea. I’ll have to keep it in mind for future projects.