...

View Full Version : Wallpapers Thumbnails



duniyadnd
03-30-2003, 11:05 PM
I've noticed a lot of people have made classes which go through a directory looking for a certain type of file (*.gif; *.png; *.jpg etc.) and puts it into an array and spits out the information with the same image information only resized.

eg. an image originally sized 800x600 is now set up as:

<img src="image.jpg" width="50" height="50" />

My question is not about how to go about this, but more about is it feasable using it! As load time would decrease considerably no matter what dimensions is set up in the image tag, because the size of the file is still the same. It does save on harddrive space though, by just keeping one file.

But wouldn't it be easier to use something along the lines of imagecopy() -> not exactly this function, but one similar to it -> which copies and shrinks the image and size and creates a temporary image for the viewer to see as a thumbnail. However, this could take up bandwidth space if excessive number of people come to see the wallpapers.

Or is the best method to create thumbnails individually and create seperate sizes?

Any suggestions?

Thanks
Duniyadnd

Phool
03-31-2003, 12:24 AM
you can use the GD lib to read any image then resize it for output.
However the GD lib itself has to be installed on your webhost. It can write text on images, create images and do all kinds of cool things. I used it to create dynamic graphs for my 'statistical recording and analysis site' (lol what a mouthfull) You might want to look into it.

Íkii
03-31-2003, 07:19 AM
create a thumbnail once and only once for any image - save it to a folder on your server and call it from the src of an img tag -
there are very very few scenarios where a different strategy should be used.
-----------------------------------

the main reasons for using thumbnails are:

reduce page load speed by reducing filesize
allow visitors to view a small representation of thee image so they can decide whether to view larger image
show multiple images on a page without taking a huge mount of space

obviously just forcing width="60" in the img tag doesn't help for page load speed at all - it also doesn't help for bandwidth

so - yes, you are going to want to have thumbnailed images sent from the server which still gives two choices (admittedly one choice is daft - you be surprised how many people do the daft thing though) :-

create thumbnails dynamically when the page is viewed (the daft option)
or
create thumbnail when the image is uploaded and save copy to server - (dir scanning and creating one thumb for each found image would be effectively this choice)

If you are using thumbnails properly the small space used to hold a server copy will be quite small (3-6KB per image) - you'd maybe compress to 70-85% to reduce filesize even more.
With a copy saved, all you need do is point the src attribute of your img tag at the relative thumbnail - saving on page load time, saving on bandwidth and saving on server resources.

If you have GD2+ you might be interested in an image manipulating class I wrote which does all the thumbnailing along with drop-shadow, merge, bevel, greyscale, motion-blur, frame etc etc - available from http://www.phpclasses.org/browse.html/package/1007.html

note: basic online demo not working at the moment as having server problems.

Shecky
03-31-2003, 12:43 PM
okii is my new all time hero.

best thumbnailer ever

duniyadnd
03-31-2003, 02:59 PM
Cool, I'll check out the information you guys suggested. Thanks

Duniyadnd



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum