views:

420

answers:

5

My web application allows users to upload images of items they are planning on selling. I'm trying to find a good compromise between having the images large enough and detailed enough for buyers to get an idea of the condition of the item and having the images small enough so that they don't slow down the site substantially.

In addition, I will also need thumbnails for a quick view of multiple items.

When a user uploads their file then, should I store both the original copy as well as a resized version on my server? If so, is there a general accepted limit on these file sizes that I should impose to get a good balance of quality and image size?

+2  A: 

Small images could still be usable - If you're trying to prevent that, I would go for small+watermark. At least that's what most stock photo sites are doing.

I would also recommend checking out Amazon s3 for storage of a large number of images. Should really help you with the server load.

yoavf
+1  A: 

Before sweating the details on size limits, do some math on how many images you'll have, what the average size will be and how much storage actually costs.

You'll find that the time you spend worrying about it isn't worth it. The storage cost is so low that your time is probably better spent on other things.

S.Lott
+1  A: 

To answer your specific questions if they are uploading a version that you are then resizing and you don't need the original then discard it. You could even consider ensuring that they upload no larger than your "full size" image requirements to save you some processing.

The limit you want to enforce will depend on all manner of factors including storage space and bandwidth available to you, file formats supported, projections of the number of items for sale and the amount of traffic, the design of the page, browser capability of the majority of your userbase...etc. There is no "generally accepted" limit.

monkey do
A: 

Don't impose any limit's to the user. The user might not have the tools or knowledge on how to reduce the size anyway. You can always resize on the server if needed.

I've created several sites that have image galleries and we normally store three files.

  1. Original (This is not necessary if for example the Preview size is big enough for all cases)

  2. Thumbnail (size depends on the design. normally around 120x80)

  3. Preview (size depends on the design. normally around 640x480)

In your case you should probably store the original. What ever sizes you choose make sure that they are same as you show in the client. Browsers are not good at resizing...

Gene
A: 

I would tackle this issue from another direction. Instead of, upon upload, generating the different file sizes that you need and storing them that way, I would do the following:

  • Resize the image down to the largest size that you'll use on the website, paying attention to DPI & W&H. Upon resize, remember to sharpen your images.
  • Only generate the smaller images upon request, but use caching to make sure that smaller images are generated only when the cache doesn't exist
  • Once storage space becomes an option, start a task that'll nuke files which haven't been accessed within x days, determining x based on the size of the data that you want to recover per run. And once x starts to get unreasonably small, you'll know its time to increase your storage capacity.
Eric Caron