gpt4 book ai didi

c# - ImageResizer 错误

转载 作者:行者123 更新时间:2023-11-30 16:18:05 24 4
gpt4 key购买 nike

我正在使用图像调整器 imageresizing.net。但是,当我尝试上传或调整图像大小时,出现错误:

The source stream is at the end (have you already read it?). You must call stream.Seek(0, SeekOrigin.Begin); before re-using a stream, or use ImageJob with ResetSourceStream=true the first time the stream is read.

using (Stream newFile =  System.IO.File.Create(Path.Combine(_pathResolver.ResolvePath(_appSettings.CompanyLogosDirectory), newFileName)) )
{
//newFile.Seek(0, SeekOrigin.Begin);

ImageResizer.ImageJob i = new ImageJob();
//i.ResetSourceStream = true;
i = new ImageResizer.ImageJob(logo.InputStream, newFile, new ImageResizer.ResizeSettings("width=120;height=45;format=jpg;mode=max"));

i.CreateParentDirectory = false; //Auto-create the uploads directory.
i.Build();
}

最佳答案

您在提供代码之前使用了 logo.InputStream(可能用于其他工作)。您可以再次阅读图像或作为异常建议在 using 语句之前放在代码下方:

logo.InputStream.Seek(0, SeekOrigin.Begin);

关于c# - ImageResizer 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16450052/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com