I am using the attached code to generate a 50 X 50 .jpg thumbnail for an uploaded image, then store the path in a database table. At our current hosting company, this works without issue. We are moving to a new company, though, and are redesigning the site, using the new host as a test environment for the new build. There, this code does not work. The following error is thrown:
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.InteropServ
on: A generic error occurred in GDI+.
Here is the stack trace:
[ExternalException (0x80004005): A generic error occurred in GDI+.]
String filename, ImageCodecInfo encoder, EncoderParameters encoderParams) +377630
String filename, ImageFormat format) +69
bject sender, EventArgs e) +7
gs e) +99
int, Boolean includeStagesAfterAsyncPoi
I've looked this up, and it appears to have something to do with the bitmap being locked, but I am unsure how to go about fixing it. Any help would be appreciated!
oldheight = originalimg.Height
oldwidth = originalimg.Width
newheight = (oldheight / oldwidth) * 50
Dim thumb As New System.Drawing.Bitmap(50, newheight)
Dim gr_dest As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(thumb)
gr_dest.DrawImage(originalimg, 0, 0, 50, newheight)
thumbpath = "/ihost/thumbs/" & itemno(x) & "thumb.jpg"
cmdstr = "UPDATE DataAuctions SET Thumb = '" & thumbpath & "' WHERE ID =" & itemno(x)
sqlcommand = New OleDbCommand(cmdstr, myconn)
rs = sqlcommand.ExecuteReader