I am uploading a big image ~10Mb and I have the following code:
public ActionResult Upload(IEnumerable<HttpPostedFileBase> files)
{
foreach (var file in files)
{
var image = Image.FromStream(file.InputStream, true, true);
...
}
}
Sometime it throws Out of Memory
, sometimes GDI+ generic errors
. I cannot reproduce this in a console app with the following code:
using (FileStream stream = File.Open(@"d:\test.jpg", FileMode.Open))
{
var image = Image.FromStream(stream);
}
What can be the cause for those exceptions? One note: for small images everything works great.