Home All Groups Group Topic Archive Search About

Getting A generic error occurred in GDI+ message

Author
25 Sep 2006 11:42 AM
Showjumper
I have set a file based photo galery. Thumbnails are generated and saved to
disk. Everything was working or so i thought until i found this problem.
When you click a link to go to a gallery everything works fine. But if you
reload that page then you get the dreaded generic error message. To it
happen go to http://riderdesign.com/photos/default.aspx?Album=EquineRotation
and then reload the page.
My code making the thumbs is this: Any idea whats happening and how to fix
this.?

Thanks
Ashok Padmanabhan

For Each oFile In oFiles

Dim ext As String = oFile.Extension.ToLower

If ext = ".jpg" Or ext = ".gif" And ThumbFile.GetLength(0) <>
oFiles.GetLength(0) Then

Dim FileName As String = oFile.Name.ToLower()

Dim g As System.Drawing.Image

Dim boxWidth As Int32 = 100

Dim boxHeight As Int32 = 100

Dim newHeight, sizer, newWidth As Double

g = System.Drawing.Image.FromFile(PhysPath & "\" & FileName)

If g.Height > g.Width Then

sizer = CDbl(boxWidth / g.Height)

Else

sizer = CDbl(boxHeight / g.Width)

End If

newWidth = Convert.ToInt32(g.Width * sizer)

newHeight = Convert.ToInt32(g.Height * sizer)

Dim g2 As New System.Drawing.Bitmap(g, CInt(newWidth), CInt(newHeight))

g.Dispose()

Dim Epars As New EncoderParameters(1)

Dim Ic As ImageCodecInfo

g2.RawFormat.Equals("jpg")

Ic = GetEncoderInfo("image/jpeg")

Epars.Param(0) = New EncoderParameter(Encoder.Quality, 90)

g2.Save(destdir & "/" & Path.GetFileName(FileName), Ic, Epars)

g2.Dispose()

g = Nothing

g2 = Nothing

Else

'do nothing

End If

Next oFile

Author
25 Sep 2006 1:56 PM
Herfried K. Wagner [MVP]
"Showjumper" <dfgkjhdf> schrieb:
> g2.Save(destdir & "/" & Path.GetFileName(FileName), Ic, Epars)

Use "\" as directory sepator or better use 'System.IO.Path.Combine'.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
Author
26 Sep 2006 12:48 AM
Showjumper
Still get the error.
Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:edCxrpK4GHA.1288@TK2MSFTNGP03.phx.gbl...
> "Showjumper" <dfgkjhdf> schrieb:
>> g2.Save(destdir & "/" & Path.GetFileName(FileName), Ic, Epars)
>
> Use "\" as directory sepator or better use 'System.IO.Path.Combine'.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>
>