Home > Generic Error > Generic Error Gdi Save

Generic Error Gdi Save


share|improve this answer edited Jul 22 '11 at 16:19 Ray Hayes 11.9k74372 answered Dec 21 '09 at 19:24 HU. 6111 add a comment| up vote 4 down vote SOLVED - I This really sucks. It is definitely being called with the correct format. Based on my testing, it's possible to create / manipulate images with a height larger than 65534, but the issue arises when saving to a stream or file IN CERTAIN FORMATS. Source

To avoid the lock, construct the image from a MemorySteam In my case the problem was that from time to time was executed a code that has tried to save img I have inserted two calls to the above method and a direct save to a file. // At this point the new bitmap has no MimeType // Need to output to Unfortunately, most of the time these Generic GDI+ errors appear to be permission-based or related to closing a stream too early or trying to save over an image you're still using. C# Jan 30, 2013 09:17 AM|PashBash|LINK The server version could be the culprit, however I cannot say for 100% I sometimes get an GDI+ error when working with images and closing http://stackoverflow.com/questions/1053052/a-generic-error-occurred-in-gdi-jpeg-image-to-memorystream

A Generic Error Occurred In Gdi C# Image Save

make sure folder have ALL THE PERMISSION. I never would have thought such a 'general' error had to do with a filesystem issue! because the using() is holding the file open, so I can't overwrite it. Member 9377677 24-Oct-13 1:09am thanks griff its solved OriginalGriff 24-Oct-13 3:00am You're welcome!

And only on a remote webserver, not on my local test machine. Maybe this will help someone in the future. I will defiantly keep patience in future. A Generic Error Occurred In Gdi In C# Windows Application Common scenario that this happens: 1) Read an image into a Bitmap object 2) Manipulate the bitmap 3) Wanting to write back the bitmap to overwrite the original image file you

Proving the irrationality of a number Why would a crash landed generation fall back to the stone age? A Generic Error Occurred In Gdi Bitmap Save C# Not the answer you're looking for? The problem was due to the loading stream being disposed. http://stackoverflow.com/questions/15571022/how-to-find-reason-for-generic-gdi-error-when-saving-an-image Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

This worked for me too! System.runtime.interopservices.externalexception (0x80004005): A Generic Error Occurred In Gdi+. share|improve this answer answered Aug 29 '12 at 14:20 MytyMyky 498514 add a comment| up vote 3 down vote Just in case if someone is doing as stupid stuff as I Can you find out which department is responsible and tell to clean that module up with some proper error handling?PRManFriday, 19 February 2010 09:52:27 UTCBroken Link: the one with the text Which keeps a lock on the file until the garbage collector runs.

A Generic Error Occurred In Gdi Bitmap Save C#

Make sure that you don't save images with duplicate name. https://forums.asp.net/t/1877056.aspx?GDI+Generic+Error+for+some+images+but+not+others+Any+Advice+C+ Make sure you call Directory.CreateDirectory(Path.GetDirectoryName(fileName)); before you try to save. A Generic Error Occurred In Gdi C# Image Save I ran into this problem today on Azure (works locally in the cloud, just an Azure 1.3 thing!), and I saw the link to the blog post above. How To Solve A Generic Error Occurred In Gdi+ The error was "A generic error occurred in GDI+" and you know that if an error is generic, it's sure in the heck not specific.

isprobaj bitmap.Dispose();//To Do…. this contact form As far as I can see, there is nothing special about the image. Edit: protected void ResizeAndSave(PropBannerImage objPropBannerImage) { // Create a bitmap of the content of the fileUpload control in memory Bitmap originalBMP = new Bitmap(fuImage.FileContent); // Calculate the new image dimensions int I'd been directly deploying some of the .dll's to the test server. A Generic Error Occurred In Gdi+. Asp.net C#

Deploying the entire solution fixed the issue, so it was probably a weird compilation mismatch share|improve this answer answered Aug 3 at 0:30 Chris Halcrow 3,89832941 add a comment| up vote All I had to do was use: image_instance = Image.FromFile(file_name); instead of image_instance.Load(file_name); image_instance is of type System.Windows.Forms.PictureBox! share|improve this answer answered Jun 24 '13 at 13:37 Igilima 8111 3 awesome - I would never have thought to look at the directory path that closely –jharr100 May 23 http://glitchtest.org/generic-error/generic-error-occurred-in-gdi-bitmap-save.html As such, I've had to look through something like 80 forum posts so far describing various GDI+ errors just to arrive at this possible conclusion.

Only had the issue with jpg images (png etc were fine) –Darren Apr 9 '15 at 19:56 2 I had this issue with .bmp, .jpg, and .png but I wasn't System.runtime.interopservices.externalexception: A Generic Error Occurred In Gdi+. I am really clueless on what causes the error. try this one - replace Bitmap newBitmap = new Bitmap(thumbBMP); thumbBMP.Dispose(); thumbBMP = null; newBitmap.Save("~/image/thumbs/" + "t" + objPropBannerImage.ImageId, ImageFormat.Jpeg); with something like: string outputFileName = "..."; using (MemoryStream memory =

share|improve this answer edited Mar 22 '13 at 13:23 answered Mar 22 '13 at 13:03 Thorsten Dittmar 41.4k25598 1 I don't really get why this answer is being downvoted ...

bmpNew.Save(fileName); } 2. sometimes this error occurs, sometimes it doesnt sometimes putting a Thread.Sleep() (for about 30 ms) helps it just before the save Monday, August 14, 2006 12:24 AM Reply | Quote Moderator Basically, the process pulls in images from the file system and displays them in the browser. A Generic Error Occured In Gdi+. Bitmap.save C# Windows Image Viewer or Paint.NET: (Since the image above, after being uploaded to Stack Overflow does not produce the error anymore, I've put the original image here) What I discovered is

This can happen because the Bitmap implementation seems to be as lazy as possible. According to IrfanView, they are the same dpi with the same compression (CCITT Group 4 Fax Encoding). Design by @jzy Knowledgebase Blog on software engineering Toggle navigation BooksPostsSite MapContentsAbout Solving: A generic error occurred in GDI+. Check This Out This then means your software has the original image file open, causing this problem when you try to overwrite it in step three.

If you are using windows server (2003,2008) or Vista, make sure that add write permission for the Network service account. Why wouldn't it be? Simply copying the image to a new Bitmap object was enough to prevent this exception from appearing: new Bitmap(oldbitmap).Save(filename); share|improve this answer answered May 8 '12 at 22:37 Segfault 4,57221836 add I discovered it would not throw the exception if the statement had a breakpoint on it, nor would it if the Bitmap.Save was preceeded by Thread.Sleep(500) so I suppose there is