I have this JPEG image, that opens fine in Picasa, Photoshop, web browser, etc., but in .NET it just refuses to work.
Image image = Image.FromFile(@"myimage.jpg");
image.Save(@"myimage2.jpg");
// ExternalException - A generic error occurred in GDI+.
Is there a way to recover it in .NET so I can work with it (I need to resize it), without fixing the problem at the source?
Full exception details:
source: System.Drawing
type: System.Runtime.InteropServices.ExternalException
message: A generic error occurred in GDI+.
stack trace:
at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams)
at System.Drawing.Image.Save(String filename, ImageFormat format)
at System.Drawing.Image.Save(String filename)
at ConsoleApplication20.Program.Main(String[] args) in C:UserssamDesktopS
ourceConsoleApplication20ConsoleApplication20Program.cs:line 16
This issue is reproducible on Windows 7.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…