【发布时间】:2018-12-20 17:28:43
【问题描述】:
我在 imageFactory.Load(inStream) 线上遇到了通用 GDI+ 错误。我的项目是 ASP.NET Core Razor-Pages。
我尝试将 inStream 克隆到新流(这在保存位图之前对我有帮助),但没有成功。
以前有人处理过类似的事情吗?
// using ImageProcessor;
// using ImageProcessor.Imaging.Formats;
byte[] photoBytes = System.IO.File.ReadAllBytes(@"C:\Users\User\Desktop\img\img.jpg");
ISupportedImageFormat format = new JpegFormat();
Size size = new Size(200,200);
using (MemoryStream inStream = new MemoryStream(photoBytes))
{
using (MemoryStream outStream = new MemoryStream())
{
var asd = inStream;
using (ImageFactory imageFactory = new ImageFactory(preserveExifData: true))
{
imageFactory.Load(inStream)
.Resize(size)
.Format(format)
.Save(@"C:\Users\User\Desktop\ImgAdjusted\");
}
}
}
【问题讨论】:
-
1.
ImageProcessor不是为.NET Core设计的,请参阅 the author's answer on SO。 2.ImageProcessor仅处于维护模式。 ImageProcessor 库的焦点已切换到新库ImageSharp -
奇怪 - 在另一个线程中,我读到这是在 .net 核心中处理图像处理的首选包。竖起大拇指
标签: c# asp.net-core razor-pages imageprocessor