
c# nuget包
I really enjoy image manipulation in code. Sure, resizing photos is fun in Photoshop, but there's something viscerally enjoyable when you change images with your own code.
我真的很喜欢用代码进行图像处理。 当然,在Photoshop中调整照片的大小很有趣,但是当您使用自己的代码更改图像时,会有一些特别有趣的事情。
I've talked about image resizing libraries like ImageResizer before, but there's certainly room for more than one. Today I want to showcase ImageProcessor, an open source "collection of lightweight libraries written in C# that allows you to manipulate images on-the-fly using .NET 4+." ImageProcessor is available on GitHub.
我之前已经讨论过像ImageResizer这样的图像调整大小的库,但是肯定有不止一个的空间。 今天,我想展示ImageProcessor ,这是一个开源的“用C#编写的轻量级库集合,它允许您使用.NET 4+即时操作图像。 ” ImageProcessor在GitHub上可用。
ImageProcessor methods include; Resize, Rotate, Rounded Corners, Flip, Crop, Watermark, Filter, Saturation, Brightness, Contrast, Quality, Format, Vignette, Gaussian Blur, Gaussian Sharpen, and Transparency.
ImageProcessor方法包括; 调整大小,旋转,圆角,翻转,裁切,水印,滤镜,饱和度,亮度,对比度,质量,格式,晕影,高斯模糊,高斯锐化和透明度。
ImageProcessor has a notable number of configuration options for web apps, and a supporting ImageProcessor.Web package as well. It's an impressive body of work.
ImageProcessor具有大量用于Web应用程序的配置选项,并且还具有支持的ImageProcessor.Web软件包。 这是令人印象深刻的工作。
I like this simple example of loading, resizing, and saving an image with their fluent API:
我喜欢这个使用流畅的API加载,调整大小和保存图像的简单示例:
// Read a file and resize it.
byte[] photoBytes = File.ReadAllBytes(file);
int quality = 70;
ImageFormat format = ImageFormat.Jpeg;
Size size = new Size(150, 0)
using (MemoryStream inStream = new MemoryStream(photoBytes))
{
using (MemoryStream outStream = new MemoryStream())
{
using (ImageFactory imageFactory = new ImageFactory())
{
// Load, resize, set the format and quality and save an image.
imageFactory.Load(inStream)
.Resize(size)
.Format(format)
.Quality(quality)
.Save(outStream);
}
// Do something with the stream.
}
}
You can easily chain functions with the API, like tinting and constraning:
您可以轻松地使用API链接函数,例如着色和约束:
imageFactory.Load(inStream)
.Constrain(size)
.Tint(Color.FromArgb(255, 106, 166, 204))
.Format(format)
.Save(outStream);
When you add ImageProcessor.Web it adds caching that takes pressure off your web servers. You can easily add HttpHandlers to watermark an image, for example, and cache the result.
添加ImageProcessor.Web时,它会添加缓存,从而减轻Web服务器的压力。 例如,您可以轻松地添加HttpHandlers来对图像加水印并缓存结果。
This is a library that has as a lot of potential. Since it's open source, I'm sure they'd appreciate help from the community! Personally, I think they could use more Unit Tests and more examples.
这是一个潜力巨大的图书馆。 由于它是开源的,我相信他们会感谢社区的帮助! 我个人认为他们可以使用更多的单元测试和更多的示例。
Head over to https://github.com/JimBobSquarePants/ImageProcessor and star this project! Get involved, file issues, and contribute! http://imageprocessor.org/
前往https://github.com/JimBobSquarePants/ImageProcessor并为该项目加注星标! 参与进来,提出问题并做出贡献! http://imageprocessor.org/
相关链接 (Related Links)
NuGet Package of Week #11 - ImageResizer enables clean, clear image resizing in ASP.NET
Back to Basics: Dynamic Image Generation, ASP.NET Controllers, Routing, IHttpHandlers
c# nuget包