Page 1 of 1

Handling images properly in PHP

Posted: Mon Mar 12, 2007 4:28 pm
by mjseaden
Hi,

I have some product images, with the source image consistently of 800 pixels in width, and varied height depending upon the image's proportions.

I want to show these same images at different sizes depending on the page - anything from 150 pixel thumbnail to 800 pixel fullsize.

I don't want to resample the image, and save to a different file for all of the 3-4 sizes I want to display the image at, as it will take up a lot of server space per image.

I also don't want to force the width of the image using the img tag property 'width', because this will always require the loading of the full size image each time the page is loaded, only it will simply be displayed at a smaller size.

Resampling on-demand seems to be an option, but doubtful...

What is the 'best' way, i.e. the one that has won in the market of ideas?

Many thanks

Posted: Mon Mar 12, 2007 5:34 pm
by califdon
Well, you know, either you have to resize them in advance, in separate files, or you have to resize them when you display them, that's the only two choices you've got. For speed in loading, do the former; for conserving disk storage, do the latter.

Posted: Tue Mar 13, 2007 7:55 am
by feyd
califdon wrote:For speed in loading, do the former; for conserving disk storage, do the latter.
On the topic of always dynamically creating the images, it will often significantly slow your page load down if you're performing multiple resizes on any given page request.