Jump to content

Dilemma - Image handling (thumbnails)


immanuelx2

Recommended Posts

Fellow PHP Coders,

 

I am working on a blogging system that will involve the use of images. Most images will be fairly large so thumbnails are a must.

 

Is there too much overhead to dynamically generate the thumbnails on-the-fly, each page load, or should the thumbnails be generated once upon upload and then saved as a separate file.

 

The reason I ask is because there will be times when I'd like thumbnails to be bigger than others (headline stories).

 

Thanks in advance for all input!

Link to comment
Share on other sites

Create a thumbnail on upload.  Just create it in the sizes you may use.  They are thumbnails after all they won't take up that much space.

 

If one image is only going to be used in one size just make an option to choose which size to create the thumbnail on upload.

 

Creating thumbnails on the fly creates unnecessary load time, creating thumbnails on upload uses unnecessary space.  For me, it'd be space.

Link to comment
Share on other sites

Hi

 

Basically agree with the above.

 

However I would be tempted to generate images of the required size on demand, but cache them. . In simple terms say you have fred.jpg uploaded which is 800x600. Upload this as normal. You then need a copy of it that is 80x60 as a thumbnail. Take the name, add the size to the end as fred800x600.jpg, check if that has already been created and if so just return it, if not then create and return it (you could hash the names if you want).

 

Thus you only bother to resize them when required, and if a future upgrade to your site means the thumbnails need to be double the size then it is easy to do.

 

Doing this I would be tempted to store the images outside the web directory and retrieve them with a script (so you can keep control and block people from viewing them if someone is hot linking to them).

 

All the best

 

Keith

Link to comment
Share on other sites

Thanks for the responses guys, really helpful.

 

I suppose I will have to carefully plan and figure out which size thumbnails I will need in advance.

 

Staying on topic, do you guys have any links to any good public PHP image handling / manipulation classes? Or perhaps any batch-processing thumbnail creation techniques

 

Thanks again

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.