.Net Core上用于代替System.Drawing的类库

目前.Net Core上没有System.Drawing这个类库,想要在.Net Core上处理图片得另辟蹊径。

微软给出了将来取代System.Drawing的方案,偏向于使用一个单独的服务端进行各种图片处理
https://github.com/dotnet/corefx/issues/2020
https://github.com/imazen/Graphics-vNext
但目前仍然没有一个可用的实现。

下面我介绍一些目前确实可用于代替System.Drawing的类库,包括我发布的ZKWeb.System.Drawing

ImageProcessor

地址: https://github.com/JimBobSquarePants/ImageProcessor/
从3.0开始支持了.Net Core。
支持的很全面,如果只用于转换缩放图片,或手动处理像素的话可以最优先考虑这个类库。
但是不支持描画验证码等描画类的功能,在将来会支持,可见https://github.com/JimBobSquarePants/ImageProcessor/issues/264

因为作者尚未把3.0发布到nuget,安装需要添加myget的源。
如何添加myget的源可以参考https://www.myget.org/nuget
添加后使用nuget安装ImageProcessorCore即可。

CoreCompat

地址: https://github.com/CoreCompat/CoreCompat
这个类库使用了mono的System.Drawing实现,只要安装了之前使用System.Drawing的代码完全不用修改。
也支持描画验证码等描画类的功能。

如果需要linux或osx支持,可以安装runtime.linux.CoreCompat.System.Drawingruntime.osx.10.10-x64.CoreCompat.System.Drawing

ZKWeb.System.Drawing

地址: https://github.com/zkweb-framework/zkweb.system.drawing
这个类库是我在使用CoreCompat后感到不满意而重新创建的一个类库,也是从mono的System.D