473,699 Members | 2,333 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Upload image and then resize it - A generic error occurred in GDI+.

Howdy,

I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders!

Now I am making a public function that will take the path of the uploaded image, and resize it with the provided dimensions. My function is below. The current function is returning an error when run from the upload function: A generic error occurred in GDI+. Not sure what exactly that means. From what I can tell, no one really knows what it means.... Here's my public function

Function ResizeImage(ByV al p As String, ByVal w As Integer, ByVal h As Integer) As String
Dim img As System.Drawing. Image
img = System.Drawing. Image.FromFile( p)
Dim iw As Integer = img.Width
Dim ih As Integer = img.Height
Dim nw, nh As Integer
Dim per As Decimal

If iw > w Or ih > h Then 'check to see if resize is necessary
If w > h Then 'get the larger dimension and get percentage
per = iw / w
Else
per = ih / h
End If

'create new sizes based on percentages
nw = iw * per
nh = ih * per

'now save it
Dim size As New Size(nw, nh)
Dim nimg As New Bitmap(img, size)
nimg.Save(p)

lblTemp.Text = "<br>Old " & iw & "x" & ih & "<br>New " & nw & "x" & nh
Else
lblTemp.Text = "No resize necessary."
End If
End Function

and here is my code for the upload, abbreviated

If picType = "image/jpeg" Or picType = "image/gif" Or picType = "image/pjpeg" Or picType = "image/bmp" Then
File.PostedFile .SaveAs(path)
ResizeImage(pat h, 120, 95)
lblError.Text = "The speaker photo uploaded sucessfully! Make sure to click Update below to save changes."
Else
lblError.Text = "Invalid image format. Only JPG, JPEG, GIF and BMP images are allowed."
End If

Again, the upload works great

Thanks!!

--
David Lozzi
Web Applications Developer
dlozzi@(remove-this)delphi-ts.com

Dec 9 '05 #1
15 5341
Besides the point, I just realized my math is wrong, please don't critique. I just need to resolve the resize issue.

--
David Lozzi
Web Applications Developer
dlozzi@(remove-this)delphi-ts.com

"David Lozzi" <Da********@nos pam.nospam> wrote in message news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
Howdy,

I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders!

Now I am making a public function that will take the path of the uploaded image, and resize it with the provided dimensions. My function is below. The current function is returning an error when run from the upload function: A generic error occurred in GDI+. Not sure what exactly that means. From what I can tell, no one really knows what it means.... Here's my public function

Function ResizeImage(ByV al p As String, ByVal w As Integer, ByVal h As Integer) As String
Dim img As System.Drawing. Image
img = System.Drawing. Image.FromFile( p)
Dim iw As Integer = img.Width
Dim ih As Integer = img.Height
Dim nw, nh As Integer
Dim per As Decimal

If iw > w Or ih > h Then 'check to see if resize is necessary
If w > h Then 'get the larger dimension and get percentage
per = iw / w
Else
per = ih / h
End If

'create new sizes based on percentages
nw = iw * per
nh = ih * per

'now save it
Dim size As New Size(nw, nh)
Dim nimg As New Bitmap(img, size)
nimg.Save(p)

lblTemp.Text = "<br>Old " & iw & "x" & ih & "<br>New " & nw & "x" & nh
Else
lblTemp.Text = "No resize necessary."
End If
End Function

and here is my code for the upload, abbreviated

If picType = "image/jpeg" Or picType = "image/gif" Or picType = "image/pjpeg" Or picType = "image/bmp" Then
File.PostedFile .SaveAs(path)
ResizeImage(pat h, 120, 95)
lblError.Text = "The speaker photo uploaded sucessfully! Make sure to click Update below to save changes."
Else
lblError.Text = "Invalid image format. Only JPG, JPEG, GIF and BMP images are allowed."
End If

Again, the upload works great

Thanks!!

--
David Lozzi
Web Applications Developer
dlozzi@(remove-this)delphi-ts.com

Dec 9 '05 #2
Hi David,

We have reviewed this issue and are currently researching on it. We will
update you ASAP. Thanks for your patience!

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Dec 10 '05 #3
Hey David,

So this seems a pure GDI+ image processing issue. Does this problem occurs
only when the uploaded image is of certain format or is a common issue that
will occur for any images that uploaded onto the server? Generally I think
we can throubleshoot through the following steps:

1. Make sure that the image is uploaded correctly onto the server , open it
in image viewer to make sure the data is not corrupted.

2. Then, use some standard image resizeing code to resize the image...
here is some simple GDI+ code I picked from net which resize the image
through percentage value:

static Image ScaleByPercent( Image imgPhoto, int Percent)
{
float nPercent = ((float)Percent/100);

int sourceWidth = imgPhoto.Width;
int sourceHeight = imgPhoto.Height ;
int sourceX = 0;
int sourceY = 0;

int destX = 0;
int destY = 0;
int destWidth = (int)(sourceWid th * nPercent);
int destHeight = (int)(sourceHei ght * nPercent);

Bitmap bmPhoto = new Bitmap(destWidt h, destHeight,
PixelFormat.For mat24bppRgb);
bmPhoto.SetReso lution(imgPhoto .HorizontalReso lution,
imgPhoto.Vertic alResolution);

Graphics grPhoto = Graphics.FromIm age(bmPhoto);
grPhoto.Interpo lationMode = InterpolationMo de.HighQualityB icubic;

grPhoto.DrawIma ge(imgPhoto,
new Rectangle(destX ,destY,destWidt h,destHeight),
new Rectangle(sourc eX,sourceY,sour ceWidth,sourceH eight),
GraphicsUnit.Pi xel);

grPhoto.Dispose ();
return bmPhoto;
}

You can try resizing through the code also to see whether it can work
correctly....

If there're any other finding, please feel free to post here.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: "David Lozzi" <Da********@nos pam.nospam>
| References: <#r************ **@TK2MSFTNGP09 .phx.gbl>
| Subject: Re: Upload image and then resize it - A generic error occurred
in GDI+.
| Date: Fri, 9 Dec 2005 11:15:17 -0500
| Lines: 270
| MIME-Version: 1.0
| Content-Type: multipart/alternative;
| boundary="----=_NextPart_000_ 0011_01C5FCB1.D 5B1AFD0"
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <#G************ **@TK2MSFTNGP09 .phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: c-24-63-42-200.hsd1.ma.com cast.net 24.63.42.200
| Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP09.phx. gbl
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3638 64
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| Besides the point, I just realized my math is wrong, please don't
critique. I just need to resolve the resize issue.
| --
| David Lozzi
| Web Applications Developer
| dlozzi@(remove-this)delphi-ts.com
| "David Lozzi" <Da********@nos pam.nospam> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
| Howdy,
| I have a function that uploads an image and that works great. I love
.Nets built in upload, so much easier than 3rd party uploaders!
| Now I am making a public function that will take the path of the
uploaded image, and resize it with the provided dimensions. My function is
below. The current function is returning an error when run from the upload
function: A generic error occurred in GDI+. Not sure what exactly that
means. From what I can tell, no one really knows what it means.... Here's
my public function
| Function ResizeImage(ByV al p As String, ByVal w As Integer, ByVal h
As Integer) As String
| Dim img As System.Drawing. Image
| img = System.Drawing. Image.FromFile( p)
| Dim iw As Integer = img.Width
| Dim ih As Integer = img.Height
| Dim nw, nh As Integer
| Dim per As Decimal
| If iw > w Or ih > h Then 'check to see if resize is necessary
| If w > h Then 'get the larger dimension and get percentage
| per = iw / w
| Else
| per = ih / h
| End If
| 'create new sizes based on percentages
| nw = iw * per
| nh = ih * per
| 'now save it
| Dim size As New Size(nw, nh)
| Dim nimg As New Bitmap(img, size)
| nimg.Save(p)
| lblTemp.Text = "<br>Old " & iw & "x" & ih & "<br>New " & nw
& "x" & nh
| Else
| lblTemp.Text = "No resize necessary."
| End If
| End Function
| and here is my code for the upload, abbreviated
| If picType = "image/jpeg" Or picType = "image/gif" Or
picType = "image/pjpeg" Or picType = "image/bmp" Then
| File.PostedFile .SaveAs(path)
| ResizeImage(pat h, 120, 95)
| lblError.Text = "The speaker photo uploaded
sucessfully! Make sure to click Update below to save changes."
| Else
| lblError.Text = "Invalid image format. Only JPG,
JPEG, GIF and BMP images are allowed."
| End If
| Again, the upload works great
| Thanks!!
| --
| David Lozzi
| Web Applications Developer
| dlozzi@(remove-this)delphi-ts.com
|
|

Dec 12 '05 #4
I've tried similar to your code. I'm writing in VB so I translated from C to
VB, that might be where its messing up, somewhere in translation. Of course
I don't have the original translation anymore, but I will work on
translating your and see how I do.

Thanks,

--
David Lozzi
Web Applications Developer
dlozzi@(remove-this)delphi-ts.com

"Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in message
news:v1******** ********@TK2MSF TNGXA02.phx.gbl ...
Hey David,

So this seems a pure GDI+ image processing issue. Does this problem occurs
only when the uploaded image is of certain format or is a common issue
that
will occur for any images that uploaded onto the server? Generally I think
we can throubleshoot through the following steps:

1. Make sure that the image is uploaded correctly onto the server , open
it
in image viewer to make sure the data is not corrupted.

2. Then, use some standard image resizeing code to resize the image...
here is some simple GDI+ code I picked from net which resize the image
through percentage value:

static Image ScaleByPercent( Image imgPhoto, int Percent)
{
float nPercent = ((float)Percent/100);

int sourceWidth = imgPhoto.Width;
int sourceHeight = imgPhoto.Height ;
int sourceX = 0;
int sourceY = 0;

int destX = 0;
int destY = 0;
int destWidth = (int)(sourceWid th * nPercent);
int destHeight = (int)(sourceHei ght * nPercent);

Bitmap bmPhoto = new Bitmap(destWidt h, destHeight,
PixelFormat.For mat24bppRgb);
bmPhoto.SetReso lution(imgPhoto .HorizontalReso lution,
imgPhoto.Vertic alResolution);

Graphics grPhoto = Graphics.FromIm age(bmPhoto);
grPhoto.Interpo lationMode = InterpolationMo de.HighQualityB icubic;

grPhoto.DrawIma ge(imgPhoto,
new Rectangle(destX ,destY,destWidt h,destHeight),
new Rectangle(sourc eX,sourceY,sour ceWidth,sourceH eight),
GraphicsUnit.Pi xel);

grPhoto.Dispose ();
return bmPhoto;
}

You can try resizing through the code also to see whether it can work
correctly....

If there're any other finding, please feel free to post here.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: "David Lozzi" <Da********@nos pam.nospam>
| References: <#r************ **@TK2MSFTNGP09 .phx.gbl>
| Subject: Re: Upload image and then resize it - A generic error occurred
in GDI+.
| Date: Fri, 9 Dec 2005 11:15:17 -0500
| Lines: 270
| MIME-Version: 1.0
| Content-Type: multipart/alternative;
| boundary="----=_NextPart_000_ 0011_01C5FCB1.D 5B1AFD0"
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <#G************ **@TK2MSFTNGP09 .phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: c-24-63-42-200.hsd1.ma.com cast.net 24.63.42.200
| Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP09.phx. gbl
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3638 64
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| Besides the point, I just realized my math is wrong, please don't
critique. I just need to resolve the resize issue.
| --
| David Lozzi
| Web Applications Developer
| dlozzi@(remove-this)delphi-ts.com
| "David Lozzi" <Da********@nos pam.nospam> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
| Howdy,
| I have a function that uploads an image and that works great. I love
Nets built in upload, so much easier than 3rd party uploaders!
| Now I am making a public function that will take the path of the
uploaded image, and resize it with the provided dimensions. My function is
below. The current function is returning an error when run from the upload
function: A generic error occurred in GDI+. Not sure what exactly that
means. From what I can tell, no one really knows what it means.... Here's
my public function
| Function ResizeImage(ByV al p As String, ByVal w As Integer, ByVal
h
As Integer) As String
| Dim img As System.Drawing. Image
| img = System.Drawing. Image.FromFile( p)
| Dim iw As Integer = img.Width
| Dim ih As Integer = img.Height
| Dim nw, nh As Integer
| Dim per As Decimal
| If iw > w Or ih > h Then 'check to see if resize is necessary
| If w > h Then 'get the larger dimension and get percentage
| per = iw / w
| Else
| per = ih / h
| End If
| 'create new sizes based on percentages
| nw = iw * per
| nh = ih * per
| 'now save it
| Dim size As New Size(nw, nh)
| Dim nimg As New Bitmap(img, size)
| nimg.Save(p)
| lblTemp.Text = "<br>Old " & iw & "x" & ih & "<br>New " &
nw
& "x" & nh
| Else
| lblTemp.Text = "No resize necessary."
| End If
| End Function
| and here is my code for the upload, abbreviated
| If picType = "image/jpeg" Or picType = "image/gif" Or
picType = "image/pjpeg" Or picType = "image/bmp" Then
| File.PostedFile .SaveAs(path)
| ResizeImage(pat h, 120, 95)
| lblError.Text = "The speaker photo uploaded
sucessfully! Make sure to click Update below to save changes."
| Else
| lblError.Text = "Invalid image format. Only JPG,
JPEG, GIF and BMP images are allowed."
| End If
| Again, the upload works great
| Thanks!!
| --
| David Lozzi
| Web Applications Developer
| dlozzi@(remove-this)delphi-ts.com
|
|

Dec 12 '05 #5
After reviewing your code, this function returns the resized image as an
image to the calling script. I need the resized image to be saved to disk.
My script is below. I get an error: Object reference not set to an instance
of an object, which pertains to the graphic object because when I remove
that chunk of code, I get the same GDI+ error.

Thanks!!

Function ResizeImage(ByV al p As String, ByVal w As Integer, ByVal h As
Integer) As String
Dim img As System.Drawing. Image
img = System.Drawing. Image.FromFile( p)
Dim iw As Integer = img.Width
Dim ih As Integer = img.Height
Dim nw, nh As Integer
Dim per As Decimal

If iw > w Or ih > h Then 'check to see if resize is necessary
If iw > ih Then 'get the larger dimension and get percentage
per = w / iw
Else
per = h / ih
End If

'create new sizes based on percentages
nw = iw * per
nh = ih * per

'now save it
Dim photo As New Bitmap(nw, nh,
Imaging.PixelFo rmat.Format24bp pRgb)
photo.SetResolu tion(img.Horizo ntalResolution,
img.VerticalRes olution)
Dim graphic As Graphics
graphic.FromIma ge(photo)
Dim img2 As Image
graphic.DrawIma ge(img, New Rectangle(0, 0, nw, nh), New
Rectangle(0, 0, iw, ih), GraphicsUnit.Pi xel)

graphic.Dispose ()
photo.Save(p)

lblTemp.Text = "<br>Per " & per & "<br>Old " & iw & "x" & ih &
"<br>New " & nw & "x" & nh
Else
lblTemp.Text = "No resize necessary."
End If
End Function

--
David Lozzi
Web Applications Developer
dlozzi@(remove-this)delphi-ts.com

"Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in message
news:v1******** ********@TK2MSF TNGXA02.phx.gbl ...
Hey David,

So this seems a pure GDI+ image processing issue. Does this problem occurs
only when the uploaded image is of certain format or is a common issue
that
will occur for any images that uploaded onto the server? Generally I think
we can throubleshoot through the following steps:

1. Make sure that the image is uploaded correctly onto the server , open
it
in image viewer to make sure the data is not corrupted.

2. Then, use some standard image resizeing code to resize the image...
here is some simple GDI+ code I picked from net which resize the image
through percentage value:

static Image ScaleByPercent( Image imgPhoto, int Percent)
{
float nPercent = ((float)Percent/100);

int sourceWidth = imgPhoto.Width;
int sourceHeight = imgPhoto.Height ;
int sourceX = 0;
int sourceY = 0;

int destX = 0;
int destY = 0;
int destWidth = (int)(sourceWid th * nPercent);
int destHeight = (int)(sourceHei ght * nPercent);

Bitmap bmPhoto = new Bitmap(destWidt h, destHeight,
PixelFormat.For mat24bppRgb);
bmPhoto.SetReso lution(imgPhoto .HorizontalReso lution,
imgPhoto.Vertic alResolution);

Graphics grPhoto = Graphics.FromIm age(bmPhoto);
grPhoto.Interpo lationMode = InterpolationMo de.HighQualityB icubic;

grPhoto.DrawIma ge(imgPhoto,
new Rectangle(destX ,destY,destWidt h,destHeight),
new Rectangle(sourc eX,sourceY,sour ceWidth,sourceH eight),
GraphicsUnit.Pi xel);

grPhoto.Dispose ();
return bmPhoto;
}

You can try resizing through the code also to see whether it can work
correctly....

If there're any other finding, please feel free to post here.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: "David Lozzi" <Da********@nos pam.nospam>
| References: <#r************ **@TK2MSFTNGP09 .phx.gbl>
| Subject: Re: Upload image and then resize it - A generic error occurred
in GDI+.
| Date: Fri, 9 Dec 2005 11:15:17 -0500
| Lines: 270
| MIME-Version: 1.0
| Content-Type: multipart/alternative;
| boundary="----=_NextPart_000_ 0011_01C5FCB1.D 5B1AFD0"
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <#G************ **@TK2MSFTNGP09 .phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: c-24-63-42-200.hsd1.ma.com cast.net 24.63.42.200
| Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP09.phx. gbl
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3638 64
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| Besides the point, I just realized my math is wrong, please don't
critique. I just need to resolve the resize issue.
| --
| David Lozzi
| Web Applications Developer
| dlozzi@(remove-this)delphi-ts.com
| "David Lozzi" <Da********@nos pam.nospam> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
| Howdy,
| I have a function that uploads an image and that works great. I love
Nets built in upload, so much easier than 3rd party uploaders!
| Now I am making a public function that will take the path of the
uploaded image, and resize it with the provided dimensions. My function is
below. The current function is returning an error when run from the upload
function: A generic error occurred in GDI+. Not sure what exactly that
means. From what I can tell, no one really knows what it means.... Here's
my public function
| Function ResizeImage(ByV al p As String, ByVal w As Integer, ByVal
h
As Integer) As String
| Dim img As System.Drawing. Image
| img = System.Drawing. Image.FromFile( p)
| Dim iw As Integer = img.Width
| Dim ih As Integer = img.Height
| Dim nw, nh As Integer
| Dim per As Decimal
| If iw > w Or ih > h Then 'check to see if resize is necessary
| If w > h Then 'get the larger dimension and get percentage
| per = iw / w
| Else
| per = ih / h
| End If
| 'create new sizes based on percentages
| nw = iw * per
| nh = ih * per
| 'now save it
| Dim size As New Size(nw, nh)
| Dim nimg As New Bitmap(img, size)
| nimg.Save(p)
| lblTemp.Text = "<br>Old " & iw & "x" & ih & "<br>New " &
nw
& "x" & nh
| Else
| lblTemp.Text = "No resize necessary."
| End If
| End Function
| and here is my code for the upload, abbreviated
| If picType = "image/jpeg" Or picType = "image/gif" Or
picType = "image/pjpeg" Or picType = "image/bmp" Then
| File.PostedFile .SaveAs(path)
| ResizeImage(pat h, 120, 95)
| lblError.Text = "The speaker photo uploaded
sucessfully! Make sure to click Update below to save changes."
| Else
| lblError.Text = "Invalid image format. Only JPG,
JPEG, GIF and BMP images are allowed."
| End If
| Again, the upload works great
| Thanks!!
| --
| David Lozzi
| Web Applications Developer
| dlozzi@(remove-this)delphi-ts.com
|
|

Dec 12 '05 #6
The object reference error is occuring on the DrawImage line, if that helps.

--
David Lozzi
Web Applications Developer
dlozzi@(remove-this)delphi-ts.com

"David Lozzi" <Da********@nos pam.nospam> wrote in message
news:O3******** ******@TK2MSFTN GP15.phx.gbl...
After reviewing your code, this function returns the resized image as an
image to the calling script. I need the resized image to be saved to disk.
My script is below. I get an error: Object reference not set to an
instance of an object, which pertains to the graphic object because when I
remove that chunk of code, I get the same GDI+ error.

Thanks!!

Function ResizeImage(ByV al p As String, ByVal w As Integer, ByVal h As
Integer) As String
Dim img As System.Drawing. Image
img = System.Drawing. Image.FromFile( p)
Dim iw As Integer = img.Width
Dim ih As Integer = img.Height
Dim nw, nh As Integer
Dim per As Decimal

If iw > w Or ih > h Then 'check to see if resize is necessary
If iw > ih Then 'get the larger dimension and get percentage
per = w / iw
Else
per = h / ih
End If

'create new sizes based on percentages
nw = iw * per
nh = ih * per

'now save it
Dim photo As New Bitmap(nw, nh,
Imaging.PixelFo rmat.Format24bp pRgb)
photo.SetResolu tion(img.Horizo ntalResolution,
img.VerticalRes olution)
Dim graphic As Graphics
graphic.FromIma ge(photo)
Dim img2 As Image
graphic.DrawIma ge(img, New Rectangle(0, 0, nw, nh), New
Rectangle(0, 0, iw, ih), GraphicsUnit.Pi xel)

graphic.Dispose ()
photo.Save(p)

lblTemp.Text = "<br>Per " & per & "<br>Old " & iw & "x" & ih &
"<br>New " & nw & "x" & nh
Else
lblTemp.Text = "No resize necessary."
End If
End Function

--
David Lozzi
Web Applications Developer
dlozzi@(remove-this)delphi-ts.com

"Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in message
news:v1******** ********@TK2MSF TNGXA02.phx.gbl ...
Hey David,

So this seems a pure GDI+ image processing issue. Does this problem
occurs
only when the uploaded image is of certain format or is a common issue
that
will occur for any images that uploaded onto the server? Generally I
think
we can throubleshoot through the following steps:

1. Make sure that the image is uploaded correctly onto the server , open
it
in image viewer to make sure the data is not corrupted.

2. Then, use some standard image resizeing code to resize the image...
here is some simple GDI+ code I picked from net which resize the image
through percentage value:

static Image ScaleByPercent( Image imgPhoto, int Percent)
{
float nPercent = ((float)Percent/100);

int sourceWidth = imgPhoto.Width;
int sourceHeight = imgPhoto.Height ;
int sourceX = 0;
int sourceY = 0;

int destX = 0;
int destY = 0;
int destWidth = (int)(sourceWid th * nPercent);
int destHeight = (int)(sourceHei ght * nPercent);

Bitmap bmPhoto = new Bitmap(destWidt h, destHeight,
PixelFormat.For mat24bppRgb);
bmPhoto.SetReso lution(imgPhoto .HorizontalReso lution,
imgPhoto.Vertic alResolution);

Graphics grPhoto = Graphics.FromIm age(bmPhoto);
grPhoto.Interpo lationMode = InterpolationMo de.HighQualityB icubic;

grPhoto.DrawIma ge(imgPhoto,
new Rectangle(destX ,destY,destWidt h,destHeight),
new Rectangle(sourc eX,sourceY,sour ceWidth,sourceH eight),
GraphicsUnit.Pi xel);

grPhoto.Dispose ();
return bmPhoto;
}

You can try resizing through the code also to see whether it can work
correctly....

If there're any other finding, please feel free to post here.

Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

--------------------
| From: "David Lozzi" <Da********@nos pam.nospam>
| References: <#r************ **@TK2MSFTNGP09 .phx.gbl>
| Subject: Re: Upload image and then resize it - A generic error occurred
in GDI+.
| Date: Fri, 9 Dec 2005 11:15:17 -0500
| Lines: 270
| MIME-Version: 1.0
| Content-Type: multipart/alternative;
| boundary="----=_NextPart_000_ 0011_01C5FCB1.D 5B1AFD0"
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| Message-ID: <#G************ **@TK2MSFTNGP09 .phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: c-24-63-42-200.hsd1.ma.com cast.net 24.63.42.200
| Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP09.phx. gbl
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3638 64
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| Besides the point, I just realized my math is wrong, please don't
critique. I just need to resolve the resize issue.
| --
| David Lozzi
| Web Applications Developer
| dlozzi@(remove-this)delphi-ts.com
| "David Lozzi" <Da********@nos pam.nospam> wrote in message
news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
| Howdy,
| I have a function that uploads an image and that works great. I love
Nets built in upload, so much easier than 3rd party uploaders!
| Now I am making a public function that will take the path of the
uploaded image, and resize it with the provided dimensions. My function
is
below. The current function is returning an error when run from the
upload
function: A generic error occurred in GDI+. Not sure what exactly that
means. From what I can tell, no one really knows what it means.... Here's
my public function
| Function ResizeImage(ByV al p As String, ByVal w As Integer, ByVal
h
As Integer) As String
| Dim img As System.Drawing. Image
| img = System.Drawing. Image.FromFile( p)
| Dim iw As Integer = img.Width
| Dim ih As Integer = img.Height
| Dim nw, nh As Integer
| Dim per As Decimal
| If iw > w Or ih > h Then 'check to see if resize is necessary
| If w > h Then 'get the larger dimension and get
percentage
| per = iw / w
| Else
| per = ih / h
| End If
| 'create new sizes based on percentages
| nw = iw * per
| nh = ih * per
| 'now save it
| Dim size As New Size(nw, nh)
| Dim nimg As New Bitmap(img, size)
| nimg.Save(p)
| lblTemp.Text = "<br>Old " & iw & "x" & ih & "<br>New " &
nw
& "x" & nh
| Else
| lblTemp.Text = "No resize necessary."
| End If
| End Function
| and here is my code for the upload, abbreviated
| If picType = "image/jpeg" Or picType = "image/gif" Or
picType = "image/pjpeg" Or picType = "image/bmp" Then
| File.PostedFile .SaveAs(path)
| ResizeImage(pat h, 120, 95)
| lblError.Text = "The speaker photo uploaded
sucessfully! Make sure to click Update below to save changes."
| Else
| lblError.Text = "Invalid image format. Only JPG,
JPEG, GIF and BMP images are allowed."
| End If
| Again, the upload works great
| Thanks!!
| --
| David Lozzi
| Web Applications Developer
| dlozzi@(remove-this)delphi-ts.com
|
|


Dec 12 '05 #7
Thanks for your response David,

I think the NullReference exception is due to the graphic object is not
correctly assigned. From the code you pasted:

=============== ==
Dim graphic As Graphics
graphic.FromIma ge(photo)
Dim img2 As Image
graphic.DrawIma ge(img, New Rectangle(0, 0, nw, nh), New
Rectangle(0, 0, iw, ih), GraphicsUnit.Pi xel)

graphic.Dispose ()
photo.Save(p)
=============== ==

You use graphic.FromIma ge(photo), this will return an Graphics object
instance, and you need to assign it to the Graphics reference, like:
.........
Dim graphic As Graphics
graphic = Graphics.FromIm age(photo)
.............
Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| From: "David Lozzi" <Da********@nos pam.nospam>
| References: <#r************ **@TK2MSFTNGP09 .phx.gbl>
<#G************ **@TK2MSFTNGP09 .phx.gbl>
<v1************ **@TK2MSFTNGXA0 2.phx.gbl>
<O3************ **@TK2MSFTNGP15 .phx.gbl>
| Subject: Re: Upload image and then resize it - A generic error occurred
in GDI+.
| Date: Mon, 12 Dec 2005 09:40:02 -0500
| Lines: 229
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| X-RFC2646: Format=Flowed; Response
| Message-ID: <O$************ **@TK2MSFTNGP15 .phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: c-24-63-42-200.hsd1.ma.com cast.net 24.63.42.200
| Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP15.phx. gbl
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3642 19
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| The object reference error is occuring on the DrawImage line, if that
helps.
|
| --
| David Lozzi
| Web Applications Developer
| dlozzi@(remove-this)delphi-ts.com
|
|
|
| "David Lozzi" <Da********@nos pam.nospam> wrote in message
| news:O3******** ******@TK2MSFTN GP15.phx.gbl...
| > After reviewing your code, this function returns the resized image as
an
| > image to the calling script. I need the resized image to be saved to
disk.
| > My script is below. I get an error: Object reference not set to an
| > instance of an object, which pertains to the graphic object because
when I
| > remove that chunk of code, I get the same GDI+ error.
| >
| > Thanks!!
| >
| > Function ResizeImage(ByV al p As String, ByVal w As Integer, ByVal h
As
| > Integer) As String
| > Dim img As System.Drawing. Image
| > img = System.Drawing. Image.FromFile( p)
| > Dim iw As Integer = img.Width
| > Dim ih As Integer = img.Height
| > Dim nw, nh As Integer
| > Dim per As Decimal
| >
| > If iw > w Or ih > h Then 'check to see if resize is necessary
| > If iw > ih Then 'get the larger dimension and get percentage
| > per = w / iw
| > Else
| > per = h / ih
| > End If
| >
| > 'create new sizes based on percentages
| > nw = iw * per
| > nh = ih * per
| >
| > 'now save it
| > Dim photo As New Bitmap(nw, nh,
| > Imaging.PixelFo rmat.Format24bp pRgb)
| > photo.SetResolu tion(img.Horizo ntalResolution,
| > img.VerticalRes olution)
| > Dim graphic As Graphics
| > graphic.FromIma ge(photo)
| > Dim img2 As Image
| > graphic.DrawIma ge(img, New Rectangle(0, 0, nw, nh), New
| > Rectangle(0, 0, iw, ih), GraphicsUnit.Pi xel)
| >
| > graphic.Dispose ()
| > photo.Save(p)
| >
| > lblTemp.Text = "<br>Per " & per & "<br>Old " & iw & "x" & ih
&
| > "<br>New " & nw & "x" & nh
| > Else
| > lblTemp.Text = "No resize necessary."
| > End If
| > End Function
| >
| > --
| > David Lozzi
| > Web Applications Developer
| > dlozzi@(remove-this)delphi-ts.com
| >
| >
| >
| > "Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in message
| > news:v1******** ********@TK2MSF TNGXA02.phx.gbl ...
| >> Hey David,
| >>
| >> So this seems a pure GDI+ image processing issue. Does this problem
| >> occurs
| >> only when the uploaded image is of certain format or is a common issue
| >> that
| >> will occur for any images that uploaded onto the server? Generally I
| >> think
| >> we can throubleshoot through the following steps:
| >>
| >> 1. Make sure that the image is uploaded correctly onto the server ,
open
| >> it
| >> in image viewer to make sure the data is not corrupted.
| >>
| >> 2. Then, use some standard image resizeing code to resize the image...
| >> here is some simple GDI+ code I picked from net which resize the image
| >> through percentage value:
| >>
| >> static Image ScaleByPercent( Image imgPhoto, int Percent)
| >> {
| >> float nPercent = ((float)Percent/100);
| >>
| >> int sourceWidth = imgPhoto.Width;
| >> int sourceHeight = imgPhoto.Height ;
| >> int sourceX = 0;
| >> int sourceY = 0;
| >>
| >> int destX = 0;
| >> int destY = 0;
| >> int destWidth = (int)(sourceWid th * nPercent);
| >> int destHeight = (int)(sourceHei ght * nPercent);
| >>
| >> Bitmap bmPhoto = new Bitmap(destWidt h, destHeight,
| >> PixelFormat.For mat24bppRgb);
| >> bmPhoto.SetReso lution(imgPhoto .HorizontalReso lution,
| >> imgPhoto.Vertic alResolution);
| >>
| >> Graphics grPhoto = Graphics.FromIm age(bmPhoto);
| >> grPhoto.Interpo lationMode = InterpolationMo de.HighQualityB icubic;
| >>
| >> grPhoto.DrawIma ge(imgPhoto,
| >> new Rectangle(destX ,destY,destWidt h,destHeight),
| >> new Rectangle(sourc eX,sourceY,sour ceWidth,sourceH eight),
| >> GraphicsUnit.Pi xel);
| >>
| >> grPhoto.Dispose ();
| >> return bmPhoto;
| >> }
| >>
| >> You can try resizing through the code also to see whether it can work
| >> correctly....
| >>
| >> If there're any other finding, please feel free to post here.
| >>
| >> Thanks,
| >>
| >> Steven Cheng
| >> Microsoft Online Support
| >>
| >> Get Secure! www.microsoft.com/security
| >> (This posting is provided "AS IS", with no warranties, and confers no
| >> rights.)
| >>
| >>
| >>
| >> --------------------
| >> | From: "David Lozzi" <Da********@nos pam.nospam>
| >> | References: <#r************ **@TK2MSFTNGP09 .phx.gbl>
| >> | Subject: Re: Upload image and then resize it - A generic error
occurred
| >> in GDI+.
| >> | Date: Fri, 9 Dec 2005 11:15:17 -0500
| >> | Lines: 270
| >> | MIME-Version: 1.0
| >> | Content-Type: multipart/alternative;
| >> | boundary="----=_NextPart_000_ 0011_01C5FCB1.D 5B1AFD0"
| >> | X-Priority: 3
| >> | X-MSMail-Priority: Normal
| >> | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| >> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| >> | Message-ID: <#G************ **@TK2MSFTNGP09 .phx.gbl>
| >> | Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| >> | NNTP-Posting-Host: c-24-63-42-200.hsd1.ma.com cast.net 24.63.42.200
| >> | Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP09.phx. gbl
| >> | Xref: TK2MSFTNGXA02.p hx.gbl
| >> microsoft.publi c.dotnet.framew ork.aspnet:3638 64
| >> | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
| >> |
| >> | Besides the point, I just realized my math is wrong, please don't
| >> critique. I just need to resolve the resize issue.
| >> | --
| >> | David Lozzi
| >> | Web Applications Developer
| >> | dlozzi@(remove-this)delphi-ts.com
| >> | "David Lozzi" <Da********@nos pam.nospam> wrote in message
| >> news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
| >> | Howdy,
| >> | I have a function that uploads an image and that works great. I
love
| >> Nets built in upload, so much easier than 3rd party uploaders!
| >> | Now I am making a public function that will take the path of the
| >> uploaded image, and resize it with the provided dimensions. My
function
| >> is
| >> below. The current function is returning an error when run from the
| >> upload
| >> function: A generic error occurred in GDI+. Not sure what exactly that
| >> means. From what I can tell, no one really knows what it means....
Here's
| >> my public function
| >> | Function ResizeImage(ByV al p As String, ByVal w As Integer,
ByVal
| >> h
| >> As Integer) As String
| >> | Dim img As System.Drawing. Image
| >> | img = System.Drawing. Image.FromFile( p)
| >> | Dim iw As Integer = img.Width
| >> | Dim ih As Integer = img.Height
| >> | Dim nw, nh As Integer
| >> | Dim per As Decimal
| >> | If iw > w Or ih > h Then 'check to see if resize is
necessary
| >> | If w > h Then 'get the larger dimension and get
| >> percentage
| >> | per = iw / w
| >> | Else
| >> | per = ih / h
| >> | End If
| >> | 'create new sizes based on percentages
| >> | nw = iw * per
| >> | nh = ih * per
| >> | 'now save it
| >> | Dim size As New Size(nw, nh)
| >> | Dim nimg As New Bitmap(img, size)
| >> | nimg.Save(p)
| >> | lblTemp.Text = "<br>Old " & iw & "x" & ih & "<br>New "
&
| >> nw
| >> & "x" & nh
| >> | Else
| >> | lblTemp.Text = "No resize necessary."
| >> | End If
| >> | End Function
| >> | and here is my code for the upload, abbreviated
| >> | If picType = "image/jpeg" Or picType = "image/gif"
Or
| >> picType = "image/pjpeg" Or picType = "image/bmp" Then
| >> | File.PostedFile .SaveAs(path)
| >> | ResizeImage(pat h, 120, 95)
| >> | lblError.Text = "The speaker photo uploaded
| >> sucessfully! Make sure to click Update below to save changes."
| >> | Else
| >> | lblError.Text = "Invalid image format. Only
JPG,
| >> JPEG, GIF and BMP images are allowed."
| >> | End If
| >> | Again, the upload works great
| >> | Thanks!!
| >> | --
| >> | David Lozzi
| >> | Web Applications Developer
| >> | dlozzi@(remove-this)delphi-ts.com
| >> |
| >> |
| >>
| >
| >
|
|
|

Dec 13 '05 #8
Hi David,

Any further progress on this issue? if there're anything else we can help,
please feel free to post here.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| X-Tomcat-ID: 53188289
| References: <#r************ **@TK2MSFTNGP09 .phx.gbl>
<#G************ **@TK2MSFTNGP09 .phx.gbl>
<v1************ **@TK2MSFTNGXA0 2.phx.gbl>
<O3************ **@TK2MSFTNGP15 .phx.gbl>
<O$************ **@TK2MSFTNGP15 .phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain
| Content-Transfer-Encoding: 7bit
| From: st*****@online. microsoft.com (Steven Cheng[MSFT])
| Organization: Microsoft
| Date: Tue, 13 Dec 2005 02:45:03 GMT
| Subject: Re: Upload image and then resize it - A generic error occurred
in GDI+.
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
| Message-ID: <Mh************ **@TK2MSFTNGXA0 2.phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| Lines: 268
| Path: TK2MSFTNGXA02.p hx.gbl
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3644 16
| NNTP-Posting-Host: tomcatimport2.p hx.gbl 10.201.218.182
|
| Thanks for your response David,
|
| I think the NullReference exception is due to the graphic object is not
| correctly assigned. From the code you pasted:
|
| =============== ==
| Dim graphic As Graphics
| graphic.FromIma ge(photo)
| Dim img2 As Image
| graphic.DrawIma ge(img, New Rectangle(0, 0, nw, nh), New
| Rectangle(0, 0, iw, ih), GraphicsUnit.Pi xel)
|
| graphic.Dispose ()
| photo.Save(p)
| =============== ==
|
| You use graphic.FromIma ge(photo), this will return an Graphics object
| instance, and you need to assign it to the Graphics reference, like:
|
|
| ........
| Dim graphic As Graphics
| graphic = Graphics.FromIm age(photo)
| ............
|
|
| Thanks,
|
| Steven Cheng
| Microsoft Online Support
|
| Get Secure! www.microsoft.com/security
| (This posting is provided "AS IS", with no warranties, and confers no
| rights.)
|
|
|
|
| --------------------
| | From: "David Lozzi" <Da********@nos pam.nospam>
| | References: <#r************ **@TK2MSFTNGP09 .phx.gbl>
| <#G************ **@TK2MSFTNGP09 .phx.gbl>
| <v1************ **@TK2MSFTNGXA0 2.phx.gbl>
| <O3************ **@TK2MSFTNGP15 .phx.gbl>
| | Subject: Re: Upload image and then resize it - A generic error occurred
| in GDI+.
| | Date: Mon, 12 Dec 2005 09:40:02 -0500
| | Lines: 229
| | X-Priority: 3
| | X-MSMail-Priority: Normal
| | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| | X-RFC2646: Format=Flowed; Response
| | Message-ID: <O$************ **@TK2MSFTNGP15 .phx.gbl>
| | Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| | NNTP-Posting-Host: c-24-63-42-200.hsd1.ma.com cast.net 24.63.42.200
| | Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP15.phx. gbl
| | Xref: TK2MSFTNGXA02.p hx.gbl
| microsoft.publi c.dotnet.framew ork.aspnet:3642 19
| | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
| |
| | The object reference error is occuring on the DrawImage line, if that
| helps.
| |
| | --
| | David Lozzi
| | Web Applications Developer
| | dlozzi@(remove-this)delphi-ts.com
| |
| |
| |
| | "David Lozzi" <Da********@nos pam.nospam> wrote in message
| | news:O3******** ******@TK2MSFTN GP15.phx.gbl...
| | > After reviewing your code, this function returns the resized image as
| an
| | > image to the calling script. I need the resized image to be saved to
| disk.
| | > My script is below. I get an error: Object reference not set to an
| | > instance of an object, which pertains to the graphic object because
| when I
| | > remove that chunk of code, I get the same GDI+ error.
| | >
| | > Thanks!!
| | >
| | > Function ResizeImage(ByV al p As String, ByVal w As Integer, ByVal
h
| As
| | > Integer) As String
| | > Dim img As System.Drawing. Image
| | > img = System.Drawing. Image.FromFile( p)
| | > Dim iw As Integer = img.Width
| | > Dim ih As Integer = img.Height
| | > Dim nw, nh As Integer
| | > Dim per As Decimal
| | >
| | > If iw > w Or ih > h Then 'check to see if resize is necessary
| | > If iw > ih Then 'get the larger dimension and get
percentage
| | > per = w / iw
| | > Else
| | > per = h / ih
| | > End If
| | >
| | > 'create new sizes based on percentages
| | > nw = iw * per
| | > nh = ih * per
| | >
| | > 'now save it
| | > Dim photo As New Bitmap(nw, nh,
| | > Imaging.PixelFo rmat.Format24bp pRgb)
| | > photo.SetResolu tion(img.Horizo ntalResolution,
| | > img.VerticalRes olution)
| | > Dim graphic As Graphics
| | > graphic.FromIma ge(photo)
| | > Dim img2 As Image
| | > graphic.DrawIma ge(img, New Rectangle(0, 0, nw, nh), New
| | > Rectangle(0, 0, iw, ih), GraphicsUnit.Pi xel)
| | >
| | > graphic.Dispose ()
| | > photo.Save(p)
| | >
| | > lblTemp.Text = "<br>Per " & per & "<br>Old " & iw & "x" &
ih
| &
| | > "<br>New " & nw & "x" & nh
| | > Else
| | > lblTemp.Text = "No resize necessary."
| | > End If
| | > End Function
| | >
| | > --
| | > David Lozzi
| | > Web Applications Developer
| | > dlozzi@(remove-this)delphi-ts.com
| | >
| | >
| | >
| | > "Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in message
| | > news:v1******** ********@TK2MSF TNGXA02.phx.gbl ...
| | >> Hey David,
| | >>
| | >> So this seems a pure GDI+ image processing issue. Does this problem
| | >> occurs
| | >> only when the uploaded image is of certain format or is a common
issue
| | >> that
| | >> will occur for any images that uploaded onto the server? Generally I
| | >> think
| | >> we can throubleshoot through the following steps:
| | >>
| | >> 1. Make sure that the image is uploaded correctly onto the server ,
| open
| | >> it
| | >> in image viewer to make sure the data is not corrupted.
| | >>
| | >> 2. Then, use some standard image resizeing code to resize the
image...
| | >> here is some simple GDI+ code I picked from net which resize the
image
| | >> through percentage value:
| | >>
| | >> static Image ScaleByPercent( Image imgPhoto, int Percent)
| | >> {
| | >> float nPercent = ((float)Percent/100);
| | >>
| | >> int sourceWidth = imgPhoto.Width;
| | >> int sourceHeight = imgPhoto.Height ;
| | >> int sourceX = 0;
| | >> int sourceY = 0;
| | >>
| | >> int destX = 0;
| | >> int destY = 0;
| | >> int destWidth = (int)(sourceWid th * nPercent);
| | >> int destHeight = (int)(sourceHei ght * nPercent);
| | >>
| | >> Bitmap bmPhoto = new Bitmap(destWidt h, destHeight,
| | >> PixelFormat.For mat24bppRgb);
| | >> bmPhoto.SetReso lution(imgPhoto .HorizontalReso lution,
| | >> imgPhoto.Vertic alResolution);
| | >>
| | >> Graphics grPhoto = Graphics.FromIm age(bmPhoto);
| | >> grPhoto.Interpo lationMode = InterpolationMo de.HighQualityB icubic;
| | >>
| | >> grPhoto.DrawIma ge(imgPhoto,
| | >> new Rectangle(destX ,destY,destWidt h,destHeight),
| | >> new Rectangle(sourc eX,sourceY,sour ceWidth,sourceH eight),
| | >> GraphicsUnit.Pi xel);
| | >>
| | >> grPhoto.Dispose ();
| | >> return bmPhoto;
| | >> }
| | >>
| | >> You can try resizing through the code also to see whether it can
work
| | >> correctly....
| | >>
| | >> If there're any other finding, please feel free to post here.
| | >>
| | >> Thanks,
| | >>
| | >> Steven Cheng
| | >> Microsoft Online Support
| | >>
| | >> Get Secure! www.microsoft.com/security
| | >> (This posting is provided "AS IS", with no warranties, and confers no
| | >> rights.)
| | >>
| | >>
| | >>
| | >> --------------------
| | >> | From: "David Lozzi" <Da********@nos pam.nospam>
| | >> | References: <#r************ **@TK2MSFTNGP09 .phx.gbl>
| | >> | Subject: Re: Upload image and then resize it - A generic error
| occurred
| | >> in GDI+.
| | >> | Date: Fri, 9 Dec 2005 11:15:17 -0500
| | >> | Lines: 270
| | >> | MIME-Version: 1.0
| | >> | Content-Type: multipart/alternative;
| | >> | boundary="----=_NextPart_000_ 0011_01C5FCB1.D 5B1AFD0"
| | >> | X-Priority: 3
| | >> | X-MSMail-Priority: Normal
| | >> | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| | >> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| | >> | Message-ID: <#G************ **@TK2MSFTNGP09 .phx.gbl>
| | >> | Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| | >> | NNTP-Posting-Host: c-24-63-42-200.hsd1.ma.com cast.net 24.63.42.200
| | >> | Path:
TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP09.phx. gbl
| | >> | Xref: TK2MSFTNGXA02.p hx.gbl
| | >> microsoft.publi c.dotnet.framew ork.aspnet:3638 64
| | >> | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
| | >> |
| | >> | Besides the point, I just realized my math is wrong, please don't
| | >> critique. I just need to resolve the resize issue.
| | >> | --
| | >> | David Lozzi
| | >> | Web Applications Developer
| | >> | dlozzi@(remove-this)delphi-ts.com
| | >> | "David Lozzi" <Da********@nos pam.nospam> wrote in message
| | >> news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
| | >> | Howdy,
| | >> | I have a function that uploads an image and that works great. I
| love
| | >> Nets built in upload, so much easier than 3rd party uploaders!
| | >> | Now I am making a public function that will take the path of the
| | >> uploaded image, and resize it with the provided dimensions. My
| function
| | >> is
| | >> below. The current function is returning an error when run from the
| | >> upload
| | >> function: A generic error occurred in GDI+. Not sure what exactly
that
| | >> means. From what I can tell, no one really knows what it means....
| Here's
| | >> my public function
| | >> | Function ResizeImage(ByV al p As String, ByVal w As Integer,
| ByVal
| | >> h
| | >> As Integer) As String
| | >> | Dim img As System.Drawing. Image
| | >> | img = System.Drawing. Image.FromFile( p)
| | >> | Dim iw As Integer = img.Width
| | >> | Dim ih As Integer = img.Height
| | >> | Dim nw, nh As Integer
| | >> | Dim per As Decimal
| | >> | If iw > w Or ih > h Then 'check to see if resize is
| necessary
| | >> | If w > h Then 'get the larger dimension and get
| | >> percentage
| | >> | per = iw / w
| | >> | Else
| | >> | per = ih / h
| | >> | End If
| | >> | 'create new sizes based on percentages
| | >> | nw = iw * per
| | >> | nh = ih * per
| | >> | 'now save it
| | >> | Dim size As New Size(nw, nh)
| | >> | Dim nimg As New Bitmap(img, size)
| | >> | nimg.Save(p)
| | >> | lblTemp.Text = "<br>Old " & iw & "x" & ih & "<br>New
"
| &
| | >> nw
| | >> & "x" & nh
| | >> | Else
| | >> | lblTemp.Text = "No resize necessary."
| | >> | End If
| | >> | End Function
| | >> | and here is my code for the upload, abbreviated
| | >> | If picType = "image/jpeg" Or picType =
"image/gif"
| Or
| | >> picType = "image/pjpeg" Or picType = "image/bmp" Then
| | >> | File.PostedFile .SaveAs(path)
| | >> | ResizeImage(pat h, 120, 95)
| | >> | lblError.Text = "The speaker photo uploaded
| | >> sucessfully! Make sure to click Update below to save changes."
| | >> | Else
| | >> | lblError.Text = "Invalid image format. Only
| JPG,
| | >> JPEG, GIF and BMP images are allowed."
| | >> | End If
| | >> | Again, the upload works great
| | >> | Thanks!!
| | >> | --
| | >> | David Lozzi
| | >> | Web Applications Developer
| | >> | dlozzi@(remove-this)delphi-ts.com
| | >> |
| | >> |
| | >>
| | >
| | >
| |
| |
| |
|
|

Dec 15 '05 #9
I updated the script a bit and also included your last post. Here's my current script which is still receiving the GDI+ genereic error. I removed the Try statement this code was in and it appears to be erroring on the line with the *

Dim img As Image

img = Image.FromFile( p)

Dim photo As New Bitmap(img)

Dim photo2 As New Bitmap(img.Hori zontalResolutio n, img.VerticalRes olution, Imaging.PixelFo rmat.Format32bp pRgb)

Dim grPhoto As Graphics

grPhoto = Graphics.FromIm age(photo)

grPhoto.DrawIma ge(photo2, New Rectangle(0, 0, iw, ih))

grPhoto.Dispose ()

photo.Dispose()

photo2.SetResol ution(nw, nh)

photo2.Save(p) *

photo2.Dispose( )
Thanks!!

--
David Lozzi
Web Applications Developer
dlozzi@(remove-this)delphi-ts.com


"Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in message news:Mh******** ******@TK2MSFTN GXA02.phx.gbl.. .
Thanks for your response David,

I think the NullReference exception is due to the graphic object is not
correctly assigned. From the code you pasted:

=============== ==
Dim graphic As Graphics
graphic.FromIma ge(photo)
Dim img2 As Image
graphic.DrawIma ge(img, New Rectangle(0, 0, nw, nh), New
Rectangle(0, 0, iw, ih), GraphicsUnit.Pi xel)

graphic.Dispose ()
photo.Save(p)
=============== ==

You use graphic.FromIma ge(photo), this will return an Graphics object
instance, and you need to assign it to the Graphics reference, like:


........
Dim graphic As Graphics
graphic = Graphics.FromIm age(photo)
............


Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)




--------------------
| From: "David Lozzi" <Da********@nos pam.nospam>
| References: <#r************ **@TK2MSFTNGP09 .phx.gbl>
<#G************ **@TK2MSFTNGP09 .phx.gbl>
<v1************ **@TK2MSFTNGXA0 2.phx.gbl>
<O3************ **@TK2MSFTNGP15 .phx.gbl>
| Subject: Re: Upload image and then resize it - A generic error occurred
in GDI+.
| Date: Mon, 12 Dec 2005 09:40:02 -0500
| Lines: 229
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| X-RFC2646: Format=Flowed; Response
| Message-ID: <O$************ **@TK2MSFTNGP15 .phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: c-24-63-42-200.hsd1.ma.com cast.net 24.63.42.200
| Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP15.phx. gbl
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3642 19
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| The object reference error is occuring on the DrawImage line, if that
helps.
|
| --
| David Lozzi
| Web Applications Developer
| dlozzi@(remove-this)delphi-ts.com
|
|
|
| "David Lozzi" <Da********@nos pam.nospam> wrote in message
| news:O3******** ******@TK2MSFTN GP15.phx.gbl...
| > After reviewing your code, this function returns the resized image as
an
| > image to the calling script. I need the resized image to be saved to
disk.
| > My script is below. I get an error: Object reference not set to an
| > instance of an object, which pertains to the graphic object because
when I
| > remove that chunk of code, I get the same GDI+ error.
| >
| > Thanks!!
| >
| > Function ResizeImage(ByV al p As String, ByVal w As Integer, ByVal h
As
| > Integer) As String
| > Dim img As System.Drawing. Image
| > img = System.Drawing. Image.FromFile( p)
| > Dim iw As Integer = img.Width
| > Dim ih As Integer = img.Height
| > Dim nw, nh As Integer
| > Dim per As Decimal
| >
| > If iw > w Or ih > h Then 'check to see if resize is necessary
| > If iw > ih Then 'get the larger dimension and get percentage
| > per = w / iw
| > Else
| > per = h / ih
| > End If
| >
| > 'create new sizes based on percentages
| > nw = iw * per
| > nh = ih * per
| >
| > 'now save it
| > Dim photo As New Bitmap(nw, nh,
| > Imaging.PixelFo rmat.Format24bp pRgb)
| > photo.SetResolu tion(img.Horizo ntalResolution,
| > img.VerticalRes olution)
| > Dim graphic As Graphics
| > graphic.FromIma ge(photo)
| > Dim img2 As Image
| > graphic.DrawIma ge(img, New Rectangle(0, 0, nw, nh), New
| > Rectangle(0, 0, iw, ih), GraphicsUnit.Pi xel)
| >
| > graphic.Dispose ()
| > photo.Save(p)
| >
| > lblTemp.Text = "<br>Per " & per & "<br>Old " & iw & "x" & ih
&
| > "<br>New " & nw & "x" & nh
| > Else
| > lblTemp.Text = "No resize necessary."
| > End If
| > End Function
| >
| > --
| > David Lozzi
| > Web Applications Developer
| > dlozzi@(remove-this)delphi-ts.com
| >
| >
| >
| > "Steven Cheng[MSFT]" <st*****@online .microsoft.com> wrote in message
| > news:v1******** ********@TK2MSF TNGXA02.phx.gbl ...
| >> Hey David,
| >>
| >> So this seems a pure GDI+ image processing issue. Does this problem
| >> occurs
| >> only when the uploaded image is of certain format or is a common issue
| >> that
| >> will occur for any images that uploaded onto the server? Generally I
| >> think
| >> we can throubleshoot through the following steps:
| >>
| >> 1. Make sure that the image is uploaded correctly onto the server ,
open
| >> it
| >> in image viewer to make sure the data is not corrupted.
| >>
| >> 2. Then, use some standard image resizeing code to resize the image...
| >> here is some simple GDI+ code I picked from net which resize the image
| >> through percentage value:
| >>
| >> static Image ScaleByPercent( Image imgPhoto, int Percent)
| >> {
| >> float nPercent = ((float)Percent/100);
| >>
| >> int sourceWidth = imgPhoto.Width;
| >> int sourceHeight = imgPhoto.Height ;
| >> int sourceX = 0;
| >> int sourceY = 0;
| >>
| >> int destX = 0;
| >> int destY = 0;
| >> int destWidth = (int)(sourceWid th * nPercent);
| >> int destHeight = (int)(sourceHei ght * nPercent);
| >>
| >> Bitmap bmPhoto = new Bitmap(destWidt h, destHeight,
| >> PixelFormat.For mat24bppRgb);
| >> bmPhoto.SetReso lution(imgPhoto .HorizontalReso lution,
| >> imgPhoto.Vertic alResolution);
| >>
| >> Graphics grPhoto = Graphics.FromIm age(bmPhoto);
| >> grPhoto.Interpo lationMode = InterpolationMo de.HighQualityB icubic;
| >>
| >> grPhoto.DrawIma ge(imgPhoto,
| >> new Rectangle(destX ,destY,destWidt h,destHeight),
| >> new Rectangle(sourc eX,sourceY,sour ceWidth,sourceH eight),
| >> GraphicsUnit.Pi xel);
| >>
| >> grPhoto.Dispose ();
| >> return bmPhoto;
| >> }
| >>
| >> You can try resizing through the code also to see whether it can work
| >> correctly....
| >>
| >> If there're any other finding, please feel free to post here.
| >>
| >> Thanks,
| >>
| >> Steven Cheng
| >> Microsoft Online Support
| >>
| >> Get Secure! www.microsoft.com/security
| >> (This posting is provided "AS IS", with no warranties, and confers no
| >> rights.)
| >>
| >>
| >>
| >> --------------------
| >> | From: "David Lozzi" <Da********@nos pam.nospam>
| >> | References: <#r************ **@TK2MSFTNGP09 .phx.gbl>
| >> | Subject: Re: Upload image and then resize it - A generic error
occurred
| >> in GDI+.
| >> | Date: Fri, 9 Dec 2005 11:15:17 -0500
| >> | Lines: 270
| >> | MIME-Version: 1.0
| >> | Content-Type: multipart/alternative;
| >> | boundary="----=_NextPart_000_ 0011_01C5FCB1.D 5B1AFD0"
| >> | X-Priority: 3
| >> | X-MSMail-Priority: Normal
| >> | X-Newsreader: Microsoft Outlook Express 6.00.2900.2670
| >> | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2670
| >> | Message-ID: <#G************ **@TK2MSFTNGP09 .phx.gbl>
| >> | Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| >> | NNTP-Posting-Host: c-24-63-42-200.hsd1.ma.com cast.net 24.63.42.200
| >> | Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!TK 2MSFTNGP09.phx. gbl
| >> | Xref: TK2MSFTNGXA02.p hx.gbl
| >> microsoft.publi c.dotnet.framew ork.aspnet:3638 64
| >> | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
| >> |
| >> | Besides the point, I just realized my math is wrong, please don't
| >> critique. I just need to resolve the resize issue.
| >> | --
| >> | David Lozzi
| >> | Web Applications Developer
| >> | dlozzi@(remove-this)delphi-ts.com
| >> | "David Lozzi" <Da********@nos pam.nospam> wrote in message
| >> news:%2******** ********@TK2MSF TNGP09.phx.gbl. ..
| >> | Howdy,
| >> | I have a function that uploads an image and that works great. I
love
| >> Nets built in upload, so much easier than 3rd party uploaders!
| >> | Now I am making a public function that will take the path of the
| >> uploaded image, and resize it with the provided dimensions. My
function
| >> is
| >> below. The current function is returning an error when run from the
| >> upload
| >> function: A generic error occurred in GDI+. Not sure what exactly that
| >> means. From what I can tell, no one really knows what it means....
Here's
| >> my public function
| >> | Function ResizeImage(ByV al p As String, ByVal w As Integer,
ByVal
| >> h
| >> As Integer) As String
| >> | Dim img As System.Drawing. Image
| >> | img = System.Drawing. Image.FromFile( p)
| >> | Dim iw As Integer = img.Width
| >> | Dim ih As Integer = img.Height
| >> | Dim nw, nh As Integer
| >> | Dim per As Decimal
| >> | If iw > w Or ih > h Then 'check to see if resize is
necessary
| >> | If w > h Then 'get the larger dimension and get
| >> percentage
| >> | per = iw / w
| >> | Else
| >> | per = ih / h
| >> | End If
| >> | 'create new sizes based on percentages
| >> | nw = iw * per
| >> | nh = ih * per
| >> | 'now save it
| >> | Dim size As New Size(nw, nh)
| >> | Dim nimg As New Bitmap(img, size)
| >> | nimg.Save(p)
| >> | lblTemp.Text = "<br>Old " & iw & "x" & ih & "<br>New "
&
| >> nw
| >> & "x" & nh
| >> | Else
| >> | lblTemp.Text = "No resize necessary."
| >> | End If
| >> | End Function
| >> | and here is my code for the upload, abbreviated
| >> | If picType = "image/jpeg" Or picType = "image/gif"
Or
| >> picType = "image/pjpeg" Or picType = "image/bmp" Then
| >> | File.PostedFile .SaveAs(path)
| >> | ResizeImage(pat h, 120, 95)
| >> | lblError.Text = "The speaker photo uploaded
| >> sucessfully! Make sure to click Update below to save changes."
| >> | Else
| >> | lblError.Text = "Invalid image format. Only
JPG,
| >> JPEG, GIF and BMP images are allowed."
| >> | End If
| >> | Again, the upload works great
| >> | Thanks!!
| >> | --
| >> | David Lozzi
| >> | Web Applications Developer
| >> | dlozzi@(remove-this)delphi-ts.com
| >> |
| >> |
| >>
| >
| >
|
|
|

Dec 15 '05 #10

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

Similar topics

3
11644
by: Alexli | last post by:
I got the error ================= An unhandled exception of typ 'System.Runtime.InteropServices.ExternalException' occurred i system.drawing.dl Additional information: A generic error occurred in GDI+ ================= the code like this
1
16227
by: Prasad More | last post by:
Hello, I am trying to write a text on Multi-page TIFF image using C# and .NET GDI+. I have written following code to do this. When I execute this code I get "Invalid Parameter User. at System.Drawing.Image.Save" error. public void addAnnotationStampOnImage() { string strStamp = Path.GetFileNameWithoutExtension(_ImageFileName); Size dSize; Image iMulti = Image.FromFile(_ImageFileName);
2
3852
by: Barry | last post by:
Hi Does anyone know why i am getting the following error message (line 64) , if i change to objBitmap.Save(Response.OutputStream, ImageFormat.Jpeg) i do not get this error Exception Details: System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+.
3
2072
by: Brent Burkart | last post by:
I have a shopping cart where I have a product page which has an image webcontrol. In my code behind, I load pictures into the image webcontrol. I would like to dynamically resize the picture (mostly jpg's) before displaying the webpage. I have read through some examples, but I am having all kinds of problems saving my resized image. A piece of my code is below. I recieve the "A generic error occurred in GDI+" error when I do the save....
1
4677
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 Image/Jpeg it works really fine. Below is the code I wrote and the error msg: ********************************************************** ERROR **********************************************************
2
1649
by: Adam J Knight | last post by:
Hi all, I am trying resize an image using the following code. //resize image System.Drawing.Image ImageUpload = System.Drawing.Image.FromFile(String.Concat(Server.MapPath(FilePath),ImageName)); // create the actual thumbnail image System.Drawing.Image ThumbnailImage =
9
3831
by: Wayne Smith | last post by:
I've come up against a major headache that I can't seem to find a solution for but I'm sure there must be a workaround and I would really be grateful of any help. I'm currently building a web site for a small club I belong to and one of the features I would like to include is the ability to allow users to upload image files. unfortunately the servers web root www folder only allows READ and EXECUTE permissions, which makes it...
9
4415
by: tshad | last post by:
Is there a way to display images (imageButtons or linkbuttons for instance) as a max size (200px by 50px) and not have it stretch the image? What I want to be able to do is limit the real estate an image can take up but not stretch the image if it happens to be 150px by 40. I am doing commands such as: <asp:ImageButton ID="CompanyLogo" onClick="Image_Click" Width="200px" Height="50px" runat="server"/>
2
3654
by: geertolaerts | last post by:
Hello, I have a problem with uploading off images to my webservice, i convert them to a byte at client side but something goes wrong when i try to convert them back to a image at server side. The webservice code: public bool PutImage(byte ImgIn) { System.IO.MemoryStream ms =
0
8694
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8621
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8928
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8890
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5877
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4379
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3060
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2013
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.