替代System.Drawing中与ASP.NET使用? [英] Alternatives to System.Drawing for use with ASP.NET?

查看:235
本文介绍了替代System.Drawing中与ASP.NET使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在追查离奇的GDI +错误的几天,我碰到这个小宝石无意中发现了 MSDN

After several days of tracking down bizarre GDI+ errors, I've stumbled across this little gem on MSDN:

类不支持Windows或ASP.NET服务中使用。尝试使用这些类从这些类型的应用程序之一中可能会产生意想不到的问题,如降低服务性能和运行时异常。

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.

我不知道ASP.NET服务是否意味着在这方面Web应用程序,但缩水服务绩效当然似乎掩盖的GDI +中发生一般性错误的随机分配,并超出内存不足的错误,我的应用程序抛出 - 间歇性的,非重复性的错误,读取和写入JPEG图像 - 在许多情况下 - 实际上是由在首位System.Drawing.Imaging创建

I don't know whether "ASP.NET service" means "web application" in this context, but "diminished service performance" certainly seems to cover the random assortment of "A generic error occurred in GDI+" and "Out of memory" errors that my app is throwing - intermittent, non-reproducible errors reading and writing JPEG images that - in many cases - were actually created by System.Drawing.Imaging in the first place.

所以 - 如果GDI +不能读写JPEG在Web应用程序文件的可靠,我应该怎么使用,而不是

我希望用户能够上传图片(JPEG要求,其他格式不错的到了),他们重新取样的可靠的,并显示有用的错误信息,如果有什么差错。有任何想法吗?从WPF的System.Media命名空间值得考虑的?

I want users to be able to upload images (JPEG required, other formats nice-to-have), resample them reliably, and display useful error messages if anything goes wrong. Any ideas? Are the System.Media namespaces from WPF worth considering?

谢谢,

迪伦

编辑:是啊,我知道GDI +作品大部分时间。这还不够好,因为当它失败时,它的方式,是不可能孤立或正常恢复这样做。我在GDI + code,为你工作的例子并不感兴趣:我正在寻找的替代库,用于图像处理

Yeah, I know GDI+ works "most of the time". That's not good enough, because when it fails, it does so in a way that's impossible to isolate or recover from gracefully. I am not interested in examples of GDI+ code that works for you: I am looking for alternative libraries to use for image processing.

推荐答案

有是一个优秀的博客文章,包括C#code有关使用的 ImageMagick的图形库通过互操作过在 TOPTEN软件博客。具体地说,这与运行下单的Linux ASP.net后的交易;然而,C#code应该完全复制粘贴能,​​你需要改变的唯一的事情是,如果你在Windows下运行引用一个窗口二进制文件(DLL)的互操作属性。

There is an excellent blog post including C# code about using the ImageMagick graphics library through Interop over at TopTen Software Blog. This post deals specifically with running ASP.net on linux under mono; however, the C# code should be perfectly copy-paste-able, the only thing you'll need to change is the Interop attributes if you are running under windows referencing a window binary (DLL).

ImageMagick®是一个软件套件来创建,编辑,撰写或转换
  位图图像。它可以读取和在各种格式写的图像
  包括DPX,EXR,GIF,JPEG,JPEG-2000,PDF PhotoCD的(超过100),
  PNG,后记,SVG和TIFF。使用ImageMagick的调整大小,翻转,
  镜像,旋转,扭曲,剪切和转换图像,调整图像
  颜色,适用于各种特殊效果,或绘制文本,线,面,
  椭圆和贝塞尔曲线。

ImageMagick® is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats (over 100) including DPX, EXR, GIF, JPEG, JPEG-2000, PDF, PhotoCD, PNG, Postscript, SVG, and TIFF. Use ImageMagick to resize, flip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.

也有上包装了你的一切codePLEX的 ImageMagick的.Net开发项目。不过,这并不表明积极发展自2009年以来,所以它可能会滞后于当前ImageMagick库的版本了。对于一个小的琐碎日常调整大小,我可能会坚持使用互操作。你只需要仔细观察你实现你自己的内存泄漏或未发布的资源(图书馆本身是行之有效的,并受到社会各界审核)。

There is also an ImageMagick .Net development project on codeplex that wraps up everything for you. But it doesn't show active development since 2009, so it may be lagging behind the current ImageMagick library version. For a small trivial resizing routine, I'd probably stick with the interop. You just need to watch your implementation carefully for your own memory leak or unreleased resources (the library itself is well tested and vetted by the community).

图书馆是免费和开源的。在Apache 2许可证似乎与个人和商业用途兼容。请参见 ImageMagick的许可证页

The library is free and open source. The Apache 2 license appears to be compatible with both personal and commercial purposes. See ImageMagick License Page.

该库是完全跨平台并实现未在GDI +中(或下单未实现)许多功能强大的图像处理和转换例程并具有良好的信誉为ASP.net图像处理的替代品。

The library is totally cross platform and implements many powerful image handling and transformation routines that are not found in GDI+ (or not implemented under mono) and has a good reputation as an alternative for ASP.net image processing.

这篇关于替代System.Drawing中与ASP.NET使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆