Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Depends on the time of year
    Posts
    478
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Wallpapers Thumbnails

    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

  • #2
    New Coder
    Join Date
    Mar 2003
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    LocalHoster.com
    Your Price. Your Features. Your Hosting™

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #4
    Regular Coder
    Join Date
    Dec 2002
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts
    okii is my new all time hero.

    best thumbnailer ever
    seldom ruined but by myself

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    Depends on the time of year
    Posts
    478
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Cool, I'll check out the information you guys suggested. Thanks

    Duniyadnd


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •