我有一个简单的方法接受file.InputStream
问题是当我第一次使用下面的方法它工作得很好但是当我第二次使用它时inputStream是空的
public static MemoryStream ConvertImageAsStream(Stream inputStream,int widthPercentage,int heightPercentage)
{
MemoryStream outputStream = new MemoryStream();
outputStream.Position = 0;
inputStream.Position = 0;
if (inputStream.Length > 0)
{
ImageJob imageJob = new ImageJob(inputStream, outputStream, imageResizeSettings);
imageJob.Instructions.AutoRotate = true;
imageJob.Build();
}
return outputStream;
}
这有效:
var imageOutputStream = ConvertImageAsStream(file.InputStream, imageWidth, imageHeight);
这不起作用:
var thumbnailOutputStream = ConvertImageAsStream(file.InputStream, thumbnailWidth, thumbnailHeight);