Looking for a library that will allow me to size and resize images using c# and ASP.net on a Windows 开发者_开发知识库2003 Server.
DISCLAIMER: I'm the author.
The free ImageResizing.Net library is precisely what you're looking for.
It's stable, mature (since 2007), actively developed, supported, and... open source.
It is specifically designed to provide image manipulation for ASP.NET, while avoiding all of the GDI bugs. It provides a highly-scalable and efficient manipulation API that often only requires 1 line of code to use. It doesn't leak memory or handles, and has 0 known bugs as of this writing.
If you decide to roll your own solution, PLEASE read this list of pitfalls to avoid. And for those thinking WIC is the solution - it is unsupported for use from ASP.NET.
Site link: ASP.NET Image Resizing Module for IIS
Another free (Microsoft blessed) alternative is System.Web.Helpers.WebImage
. WebImage
is part of the ASP.NET Web Pages library.
After installation, the assemblies are located in:
Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies
Example
public void GetResized()
{
new WebImage(ImagePath)
.Resize(200, 200) // resize image to 200x200 px
.Write();
}
Other example usages here.
Just use the built-in classes in the System.Drawing
namespace: http://msdn.microsoft.com/en-us/library/system.drawing.image.aspx
Note, as was pointed out in the comment below, the Windows Imaging Components may be a better fit.
Here is a tutorial: http://www.switchonthecode.com/tutorials/csharp-tutorial-image-editing-saving-cropping-and-resizing
I'm currently using Atalasoft Photo (Free) DotImage SDK for basic image manipulation:
http://www.atalasoft.com/products/dotimage/feature-matrix
Works well for my needs and including thumbnail processing & cropping and has tons of image format support which also comes free with the SDK.
精彩评论