tags:

views:

84

answers:

5

I want to use GD library in my PHP script to generate a small thumbnail of a random big picture from external server. Every time the page is called, the GD library will regenerate a thumbnail and show it.

Will this slow down the server or use up an unusual amount of memory?

+1  A: 

sure it will slow down the server it also depends on the size of the image you are using. why don't you just save the thumbnail-image?

antpaw
A: 

If you generate a new thumbnail every page load, it will take extra processing time. Depending on the amount of images you are thumbnailing as well as their original sizes, you may or may not notice slowness. If there is anyway you can create the thumbnail on the first page load and save it, and load the pre-created version for other page loads, you will be better off.

Jage
+2  A: 

GD use a lot of memory. It loads the image into memory entirely and uncompresses it, so you will need at least 32 bits per pixel. An image with the size 800 x 600 do then use up:

800 * 600 * 32 bits = 15.4 megabit = 2 MB

This is only to load the image. I have heard that it will use the double of this if you do resizing, and if your images are even bigger it will be even more memory.

You should really consider caching your thumbnails so they only have to be generated once (this will speed up the page for your visitors too!).

I also read now that you are loading the images from an external server, in which case you REALLY must cache the image because otherwise your visitors have to wait for YOU to download the entire image first. This gets even worse if the external server is down or overloaded and your visitors will have to wait for a timeout (this will look like it's your service that is slow). In addition to this you will waste a lot of bandwidth if you download the iamge every time a user requests a thumbnail of it.

Emil Vikström
+1  A: 

Depends on what you are doing with it, but why not try for yourself:

Gordon
A: 

Any kind of image processing is likely to be memory intensive.

If you can cache these images so as not to regenerate them with every hit to the page, that'd be a great move.

A PHP library that deals with a lot of this caching for you is phpThumb - it's probably ideal for tasks like these.

http://phpthumb.sourceforge.net/

woodywould