I'm trying to save a file using GDI+, but I just get a "A generic error occurred in GDI+" exception. The code works fine for almost every photo but this one (we handle thousands a day for years and this is the first I've heard of it). I think it might have something to do with exif data or perhaps something else odd from the photographers camera or editor.
And here is code to reproduce the error with this photo:
class Program
{
static void Main(string[] args)
{
using (var img = Image.FromFile("Err.jpg"))
using (var ms = new MemoryStream())
{
img.Save(ms, ImageFormat.Jpeg);
}
}
}
How am I supposed to handle this in GDI+? Is there a way to strip out the extra stuff that is causing the problem?