[thelist] Web-Based Hidden Image Optimization

Reha Sterbin rsterbin at stwing.upenn.edu
Wed Jan 26 08:52:19 CST 2005

On Mon, Jan 24, 2005 at 08:25:58AM -0600, Rob Smith wrote:
> :-\
> I have a feature on one of my sites that allows the user to upload an image.
> However, I would also like to limit the physical width's and heights to A)
> 100 x 100 (small thumbnail) B) 200 x 200 (large thumbnail) C) 600 x 450
> (photo gallery)...
> Sure I can force a ... width="200" in the image tag, but in some cases, the
> images default width is smaller thereby pixilating the image. 
> Are there any "plug-ins" for what I'm trying to accomplish. Open-source or
> for purchase are ok. Anything on php is preferred.
> Side bar history: Digital cameras are increasingly getting better, and the
> users are growing less savvy about proper image editing for web placement. I
> need to counter this some how.

PHP allows you to get a physical image size:


The cheap and easy way to do it is to make it clear on the form what your
required dimensions are, and throw out any uploads that exceed it.  It won't
save bandwidth (as it doesn't prevent users from *trying* to upload too-large
images), but it will get the job done.

If you wanted a way that was less dependent on the users' ability to resize
images, you could use the GD image library to do it yourself:


...but then, you still have the bandwidth problem, and to solve that, you'd
need some sort of client-side scripting.  I have no idea whether JavaScript can
handle that sort of thing.

Good luck!

/(bb|[^b]{2})/ ...THAT is the question.

More information about the thelist mailing list