Nateous
Nateous

Reputation: 787

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

Not sure what I'm missing.

Trying to take a jpg from a simple input[type=file] POST and scrub it into two versions (1800x1800) and (400x400).

Code:

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();

Throws:

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

stream comes from context.Request.InputStream I'm just passing it through a method call. and the other is MemoryStream origStream = new MemoryStream() from a wrapped using

I've read through some of the docs and some of the other SO posts that reference this error. All of the ones that I found on SO reference using a plugin, I'm using no plugins.

My best guess is that I'm missing some configuration to get ImageResizer to work, but I haven't been able to find that yet.

PS I am able to save the file if I skip the image processing step, so the image stream is good, I just can't use ImageResizer to change it.

Upvotes: 0

Views: 1188

Answers (1)

Nateous
Nateous

Reputation: 787

Problem was in the input stream.

context.Request.InputStream

should be:

context.Request.Files[0].InputStream

The InputStream hanging off of Request contains the entire body, form and all. NOT a valid image.

Upvotes: 1

Related Questions