简体   繁体   English

aspnetVnext核心CLR中缺少System.Drawing命名空间

[英]System.Drawing namespace missing in aspnetVnext core CLR

System.drawing namespace is not available in the coreCLR . CoreCLR中没有System.drawing命名空间。 I want to resize the image in the server and return store it. 我想调整服务器中的图像大小并返回存储它。

To give more context my application uses markdown for content edition . 为了提供更多上下文,我的应用程序使用markdown进行内容编辑 once the image is uploaded I want to resize and apply it in HTML . 上传图片后,我想调整大小并将其应用于HTML。 I am making an assembly to work with coreclr not on the desktop . 我正在制作一个与coreclr一起使用的程序集,而不是在桌面上。

The short answer (and only answer, for now) is yes, you're totally correct. 简短的答案(现在只有答案)是肯定的,你是完全正确的。 System.Drawing isn't and will never be a good option for Core, especially since it's cross platform. System.Drawing不是并且永远不会是Core的一个好选择,特别是因为它是跨平台的。 We are looking at other solutions like a managed libgd wrapper as discussed here https://github.com/imazen/Graphics-vNext 我们正在寻找其他解决方案,如托管的libgd包装器,如下所述https://github.com/imazen/Graphics-vNext

Alexander Köplinger started porting Mono's implementation of System.Drawing (and WinForms) to .NET Core. AlexanderKöplinger开始将Mono的System.Drawing(和WinForms)实现移植到.NET Core。 You can find his code at github.com/akoeplinger/mono-winforms-netcore . 你可以在github.com/akoeplinger/mono-winforms-netcore找到他的代码。

As fair warning though, he did say this about it: 尽管如此,他确实这样说过:

Mono's WinForms implementation didn't get much love in the recent years, so not sure if it has much use outside of experimental/hobby-stuff apps. Mono的WinForms实现近年来并没有太多的爱,所以不确定它是否在实验/业余爱好应用程序之外有很多用途。

如果你在Windows上,你可以尝试Magick.Net(包装ImageMagick) https://magick.codeplex.com/

A great and easy way to do picture conversion and manipulation is to use Magick.NET (sample code for illustration): 一个简单易用的图片转换和操作方法是使用Magick.NET (示例代码示例):

using( MagickImage ThisPicture = new MagickImage( JpegPicture ) )
{
    ThisPicture.Scale( XDimensions, YDimensions );
    ThisPicture.ColorType = ColorType.Grayscale;
    ThisPicture.Extent( XDimensions, YDimensions, Gravity.Center, MagickColors.Black );

    using( PixelCollection ThisPixels = ThisPicture.GetPixels() )
    {
        byte Intensity = ThisPixels[ IX, IY ].GetChannel( 0 );
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM