views:

150

answers:

5

Can i create round images with asp.net? Please advise. My requirement is to upload any image and get a rounded version of that created bu asp.net. I am using .Net framework 3.5, visual studio .net 2008.

Many thanks in advance.

A: 

You can do it with GDI+ at least. A short answer: use .Graphics.SetClip() to set your desired shape and then draw you image. Everything outside the clipping region will be cut away.

Here's an article disussing a method that will bring smoother corners (and even softed edges if you like): http://danbystrom.se/2008/08/24/soft-edged-images-in-gdi/

danbystrom
A: 

First of all you have to find yourself a library that can do such thing to an image. I've found sth on CodeProject http://www.codeproject.com/KB/GDI-plus/rounded%5Fcorners.aspx but I'm not sure if this is going to work with asp.net (that's basically a thing that you should google).

Then when you have a library you do your job with uploading a file and when it's uploaded you check the mime-type, try to open it and use the library.

kubal5003
Assuming what danbystrom wrote I suppose that the library from CP is also going to work, because it uses GDI.
kubal5003
A: 

I think, you can save image straight away and when you want to display, you can show these images as rounded using jquery... check these links...

http://www.malsup.com/jquery/corner/

http://www.malsup.com/jquery/corner/image.html

Muhammad Akhtar
A: 

Drawing and image manipulation with GDI+ is straightforward as the other answers suggested.

But please note this is an unsupported path, as stated by this MSDN article (emphasis added by myself).

Classes within the System.Drawing namespace are not supported for use within a Windows or ASP.NET service. Attempting to use these classes from within one of these application types may produce unexpected problems, such as diminished service performance and run-time exceptions.

I have successfully used GDI+ within an ASP.NET application several times, and have never faced any problems, but I guess it's just good to know.

kay.herzam
A: 

You haven't mentioned whether this is web or not, but have you considered rounding the images with css and/or javascript? Once you remove that image detail you can't get it back! What if the client wants a different clip shape later?

ScottE