473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problem: getting generic error in gdi+


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/defaul...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 '06 #1
2 1379
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" <dfgkjhdfwrote in message
news:eT**************@TK2MSFTNGP02.phx.gbl...
>
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/defaul...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 '06 #2
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" <dfgkjhdfwrote in message
news:eT**************@TK2MSFTNGP02.phx.gbl...

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/defaul...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 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Pohihihi | last post by:
I am getting a generic GDI+ error on following code. Basically it is trying to capture screen image and save in a file. Is there a way to find more details on this error? Thanks for the help. ...
2
by: Alphonse Giambrone | last post by:
I am currently reading 'Programming The Web with Visual Basic .NET' and have so far found it to be excellent. Downloaded all the code from Apress and working in chapter 4, I get the error shown...
3
by: T. Davis | last post by:
In C#, I am able to successfully stream a TIFF image that comes from a BLOB field in a database, save it to file, then convert the pages within TIFF file into jpegs (using GDI+) and display on the...
1
by: Fahad Aijaz | last post by:
Hi, I am trying to display a Png image via ASP .NET. I get the image from the stream, creates the Bitmap, set the content type to Image/Png, but it give an error. If I set the content type to...
7
by: Nathan Sokalski | last post by:
I am having a problem saving an image with the same name it originally had. I have two similar versions of my code, one in which I close the FileStream used to open the original image before saving,...
3
by: garyusenet | last post by:
Hello everyone I hope you are having a good evening. This evening I made a method that allows me to find the process id's of running processes of a given 'friendly name' - using...
14
by: James Wong | last post by:
Hi everybody, I'm facing a serious trouble relating to GDI+ generic error. The error message is "A Generic error occured in GDI+" and the following information is stored in Excepton object:...
3
by: Leo Seccia | last post by:
Hello everyone, I have a c# project with a sql server database. I have a number of lookup tables in my database which I successfully managed to import into my LINQ dataclasses. eg. Table:...
1
by: Jeff | last post by:
hi asp.net 2.0 I'm experimenting with GDI+ in asp.net and get an "A generic error occurred in GDI+." exception. Below is my code, I've marked a line with "<<<<-- here". It's here the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.