我在 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\");
}
}
}