Wednesday, August 11, 2010

How do I restrict the height and width (100x100) on an image my users upload to my ASP web site?

I would like users to my web site (built in ASP) to be able to upload a small thumbnail image of themselves through their member account so that I can output the image on other pages without the pages being thrown askew due to random image sizes. I do not have the budget to buy an application to do this and am curious if there is some way I can have the ASP code restrict this. I want each user to have a photo that is exactly 100 pixels by 100 pixels, and I'm not concerned about the file size (kb, mb, etc.) just the dimensions of the image.How do I restrict the height and width (100x100) on an image my users upload to my ASP web site?
Here is a tutorial for creating thumbnails with ASP.





http://www.codeproject.com/asp/thumbtool鈥?/a>How do I restrict the height and width (100x100) on an image my users upload to my ASP web site?
You could try incorporating Flash into your site. In that scenario, you could use a Flash Component called Loader in order to restrict the image's size.


Once your Flash document is done, you can easily place it within ASP pages.


Good luck!
You can't stop the user from uploading an image of a certain size, but you can take action *after* they have uploaded. If you were using asp.net, I would recommend using the built-in classes to resize the image, but I dont think there is any built-in way to do that in ASP (if you dont want to buy a third party component).





So, you could consider displaying the image with a fixed size right in the IMG tag, or using a CSS style. If size of upload (and download) is not a problem, controlling the size at display time could help achieve what you are trying to achieve.





Vikas
Use a program like AspJpeg to analyze the width and height of the photo, but that will only work after you have uploaded it. You could upload it to a temporary location, check the width and height with AspJpeg, and delete it if it doesnt fit your requirements. Hope it helps!

No comments:

Post a Comment