Problem: getting generic error in gdi+

Discussion in 'ASP .Net' started by Showjumper, Sep 25, 2006.

  1. Showjumper

    Showjumper Guest

    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
    Showjumper, Sep 25, 2006
    #1
    1. Advertising

  2. Showjumper,

    Perhaps you have a corrup file in there? Try setting a breakpoint and
    stepping through your code. See which image your code errors out on. Is it
    the very first image? How many images does your code convert successfully
    before the error occurrs? If the error occurrs after a few images are
    successfully converted then you may have to test if you have a valid image
    to convert before attempting said conversion.

    Regards,

    --
    S. Justin Gengo
    Web Developer / Programmer

    Free code library:
    http://www.aboutfortunate.com

    "Out of chaos comes order."
    Nietzsche


    "Showjumper" <dfgkjhdf> wrote in message
    news:...
    >
    > 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
    >
    >
    >
    S. Justin Gengo, Sep 25, 2006
    #2
    1. Advertising

  3. Showjumper

    Guest

    All images convert to thumbs. I upload the orginal full size images
    (around 600 px wide). Then on pade load the thumbnail gen sub fires
    making the thumbs and the thumbs directory. The error appears only when
    the page is refreshed in the browser. As long as you navigate the
    gallery via the links then now error. Just on page refresh.
    S. Justin Gengo wrote:
    > Showjumper,
    >
    > Perhaps you have a corrup file in there? Try setting a breakpoint and
    > stepping through your code. See which image your code errors out on. Is it
    > the very first image? How many images does your code convert successfully
    > before the error occurrs? If the error occurrs after a few images are
    > successfully converted then you may have to test if you have a valid image
    > to convert before attempting said conversion.
    >
    > Regards,
    >
    > --
    > S. Justin Gengo
    > Web Developer / Programmer
    >
    > Free code library:
    > http://www.aboutfortunate.com
    >
    > "Out of chaos comes order."
    > Nietzsche
    >
    >
    > "Showjumper" <dfgkjhdf> wrote in message
    > news:...
    > >
    > > 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
    > >
    > >
    > >
    , Sep 25, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alphonse Giambrone

    Generic Error in GDI+

    Alphonse Giambrone, Jul 30, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    5,630
    Alphonse Giambrone
    Jul 30, 2003
  2. T. Davis
    Replies:
    4
    Views:
    20,075
    SeanMcIlvenna
    May 19, 2009
  3. =?Utf-8?B?VGltOjouLg==?=

    Error Saving Images: A generic error occurred in GDI+.

    =?Utf-8?B?VGltOjouLg==?=, May 18, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    40,360
    =?Utf-8?B?VGltOjouLg==?=
    May 18, 2004
  4. David Lozzi
    Replies:
    15
    Views:
    6,834
    Steven Cheng[MSFT]
    Dec 20, 2005
  5. Robin van de Water [synthesiSFactory]

    GDI+ is not properly initialized (internal GDI+ error).

    Robin van de Water [synthesiSFactory], Jan 10, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    1,326
    Robin van de Water [synthesiSFactory]
    Jan 10, 2007
Loading...

Share This Page