Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Restricting uploaded photo sizes 1

Status
Not open for further replies.

Glasgow

IS-IT--Management
Jul 30, 2001
1,669
0
0
GB
I am developing a site which allows registered members to upload a personal (colour) photograph to the site for others to view in the same way as many forums do. For the moment I expect most photos to be about passport size in terms of on-screen display. Perhaps up to 150 x 150 pixels. I won't know the resolution.

In order to avoid unnecessary wasted disk space and to maintain reasonably quick load/display times, I need to set a sensible maximum limit on the file size of these images and I am happy with the logic required to control this. What I am uncertain about, however, is what kind of limit to impose.

Any suggestions?
 
I had this problem a little while back.

You could simply set a hard limit of 2x's what a decent JPEG would be (around 40k). You may want to validate the size of the image, to not have weird scaling issues later.

Here's what I did with a "avatar" image:

Notify the user what size you will save their image at.
Let the user upload just about any image.
Use the .Net framework to resize and convert it to a PNG.
PNGs have slightly better clarity than a jpg and will be a decent size.
This removes having to worry about code laced GIFs and overly huge BMPs.
This also allows for a transparency for those that select a GIF or PNG.

HTH,
Lodlaiden

If [blue]you have problems[/blue], I want [green]source code[/green] AND [green]error messages[/green], none of this [red]"there was an error crap"[/red]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top