Answered by:
Error saving images?

Question
-
User-1103495211 posted
I've made a code wich saves a remote image, locally it runs perfect, on the server it was running well, but right now i got a problem...
ill get this error remote:Server Error in '/' Application.
--------------------------------------------------------------------------------A generic error occurred in GDI+.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams) +397778
System.Drawing.Image.Save(String filename, ImageFormat format) +69
System.Drawing.Image.Save(String filename) +22
JumpTide.Weather.GetWeather(String Url) +210
MasterPage.getWeather() +35
MasterPage.Page_Load(Object sender, EventArgs e) +190
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +33
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1436
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.1433; ASP.NET Version:2.0.50727.1433This is the code, but what is the problem?????
1 public static void GetWeather(string Url) 2 { 3 string Filename = LazyAssFilename(); //= datum.jpg 4 if (File.Exists(ConfigurationManager.AppSettings["localPath"] + @"\temp\" + Filename)) 5 { 6 //Do nothing file exists 7 } 8 else 9 { 10 UrlScreenshot Shot = new UrlScreenshot(Url); 11 int newHeight = (Shot.Bitmap.Width / 400) * Shot.Bitmap.Height; 12 Shot.Crop(260, 179); 13 14 //Temp save file 15 Shot.Bitmap.Save(ConfigurationManager.AppSettings["localPath"] + @"\temp\t" + Filename); 16 System.Drawing.Image dbImage = System.Drawing.Image.FromFile(ConfigurationManager.AppSettings["localPath"] + @"\temp\t" + Filename); 17 18 int height = dbImage.Size.Height; 19 int width = dbImage.Size.Width; 20 21 System.Drawing.Image empty = new Bitmap(181, 81); 22 Graphics g = Graphics.FromImage(empty); 23 g.DrawImage(dbImage, -8, -26, 190, 110); 24 g.Save(); 25 26 empty.Save(ConfigurationManager.AppSettings["localPath"] + @"\temp\" + Filename); 27 28 g.Dispose(); 29 } 30 //return Filename; 31 } 32 33 34 public static string LazyAssFilename() 35 { 36 return DateTime.Now.ToShortDateString() + ".jpg"; 37 // IP: HttpContext.Current.Request.UserHostAddress.Replace(".", "-") + ".jpg"; // 38 }
Friday, June 5, 2009 6:29 AM
Answers
-
User-1659704165 posted
Hi,
does your asp.net page have permission to write to the local
filesystem?
grant write access to ASPNET account for that folder.
http://www.velocityreviews.com/forums/t121887-gdi-and-save-jpg-or-bmp-on-the-server.html
Check the above link- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, June 5, 2009 6:43 AM
All replies
-
User-1659704165 posted
Hi,
does your asp.net page have permission to write to the local
filesystem?
grant write access to ASPNET account for that folder.
http://www.velocityreviews.com/forums/t121887-gdi-and-save-jpg-or-bmp-on-the-server.html
Check the above link- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, June 5, 2009 6:43 AM -
User-1103495211 posted
Right now i can write new images.. thanks!Friday, June 5, 2009 7:03 AM