I am using php and mysql. I allow my registered users to upload photos, the photos are store in filesystem format, then I will keep the original/max size of : width: 1600px and heigh: 1200px. In the user profile page, I would like to display the image, it maybe one of the 5 types of thumnails: 500×500, 300×300, 200×200, 100×100 or 50×50. What is the best way to create the thumbnails, here are my current solutions:
-
I am thinking of create 1 thumbnail, then from that thumbnail, i will resize in [img src=”” width=”XX”] tag, alternatively, store the different thumbnails size in database, then get and display it
-
Create 5 thumbnails for each photos? (I am afraid this is a bad way)
Whats the best practices?
Don’t use the width HTML attribute to resize, because that will waste both your and the client’s bandwidth. You need to should serve all the images you use with the exact size desired. Where and whether you store the thumbnails depends on the on the usage pattern. A possible compromise would be to store them in memcached. Also, don’t forget about HTTP caching.