Can't get around ImageResizer error: File may be corrupted, empty, or may contain a PNG image with a single dimension greater than 65,535 pixels

Can't get around ImageResizer error: File may be corrupted, empty, or may contain a PNG image with a single dimension greater than 65,535 pixels

不确定我错过了什么。

尝试从一个简单的输入[type=文件]中获取一个 jpg POST并将其擦洗成两个版本 (1800x1800) 和 (400x400)。

代码:

stream.Position = 0;//probably only need one of these lines
stream.Seek(0, SeekOrigin.Begin);//i've tried both to no avail
ImageJob job = new ImageJob(stream, origStream, 
    new Instructions("maxwidth=1800&maxheight=1800")).Build();

投掷:

File may be corrupted, empty, 
or may contain a PNG image with a single dimension greater than 65,535 pixels.

stream 来自 context.Request.InputStream 我只是通过方法调用传递它。另一个是 MemoryStream origStream = new MemoryStream() 来自包裹的 using

我已经通读了一些文档和其他一些引用此错误的 SO 帖子。我在 SO 上找到的所有引用都使用插件,我没有使用插件。

我最好的猜测是我缺少一些让 ImageResizer 工作的配置,但我还没有找到它。

PS如果我跳过图像处理步骤,我可以保存文件,所以图像流很好,我不能使用 ImageResizer 来改变它。

问题出在输入流中。

context.Request.InputStream

应该是:

context.Request.Files[0].InputStream

RequestInputStream 挂起包含整个 body、表单和所有内容。不是有效图片。