By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,950 Members | 1,855 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,950 IT Pros & Developers. It's quick & easy.

image resizing

P: n/a
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.
Can anyone point out my problem.

Thanks so much

objImage = objImage.FromFile(Server.MapPath(strFilename))
If objImage.Width > objImage.Height Then 'portrait

shtWidth = 350

' Work out a proportionate height from width

shtHeight = objImage.Height / (objImage.Width / shtWidth)

Else 'landscape

shtHeight = 370

' Work out a proportionate width from height

shtWidth = objImage.Width / (objImage.Height / shtHeight)

End If

' Create thumbnail

objThumbnail = objImage.GetThumbnailImage(shtWidth, _

shtHeight, Nothing, System.IntPtr.Zero)

' Send down to client

Response.ContentType = "image/jpeg"

objThumbnail.Save(Path.Combine(Server.MapPath(strP ath), strFilename2 & "2"),
Imaging.ImageFormat.Jpeg)

ProductImage.ImageUrl = strFilename2

objImage.Dispose()

objThumbnail.Dispose()
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Does your application have permission to write to the filesystem?

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

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

"Brent Burkart" <Br***********@wvmb.com> wrote in message
news:Oz**************@TK2MSFTNGP12.phx.gbl...
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.
Can anyone point out my problem.

Thanks so much

objImage = objImage.FromFile(Server.MapPath(strFilename))
If objImage.Width > objImage.Height Then 'portrait

shtWidth = 350

' Work out a proportionate height from width

shtHeight = objImage.Height / (objImage.Width / shtWidth)

Else 'landscape

shtHeight = 370

' Work out a proportionate width from height

shtWidth = objImage.Width / (objImage.Height / shtHeight)

End If

' Create thumbnail

objThumbnail = objImage.GetThumbnailImage(shtWidth, _

shtHeight, Nothing, System.IntPtr.Zero)

' Send down to client

Response.ContentType = "image/jpeg"

objThumbnail.Save(Path.Combine(Server.MapPath(strP ath), strFilename2 & "2"), Imaging.ImageFormat.Jpeg)

ProductImage.ImageUrl = strFilename2

objImage.Dispose()

objThumbnail.Dispose()

Nov 18 '05 #2

P: n/a
I am not sure. I have given my aspnet accounts permission to the folders.
Is this what you are asking?

"Eric Lawrence [MSFT]" <e_********@hotmail.com> wrote in message
news:em**************@tk2msftngp13.phx.gbl...
Does your application have permission to write to the filesystem?

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.
"Brent Burkart" <Br***********@wvmb.com> wrote in message
news:Oz**************@TK2MSFTNGP12.phx.gbl...
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. Can anyone point out my problem.

Thanks so much

objImage = objImage.FromFile(Server.MapPath(strFilename))
If objImage.Width > objImage.Height Then 'portrait

shtWidth = 350

' Work out a proportionate height from width

shtHeight = objImage.Height / (objImage.Width / shtWidth)

Else 'landscape

shtHeight = 370

' Work out a proportionate width from height

shtWidth = objImage.Width / (objImage.Height / shtHeight)

End If

' Create thumbnail

objThumbnail = objImage.GetThumbnailImage(shtWidth, _

shtHeight, Nothing, System.IntPtr.Zero)

' Send down to client

Response.ContentType = "image/jpeg"

objThumbnail.Save(Path.Combine(Server.MapPath(strP ath), strFilename2 &

"2"),
Imaging.ImageFormat.Jpeg)

ProductImage.ImageUrl = strFilename2

objImage.Dispose()

objThumbnail.Dispose()


Nov 18 '05 #3

P: n/a
Basically. Can you save any file (E.g. a simple text file) from the ASP.NET
page into the target folder?
--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

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

"Brent Burkart" <Br***********@wvmb.com> wrote in message
news:uN**************@TK2MSFTNGP10.phx.gbl...
I am not sure. I have given my aspnet accounts permission to the folders.
Is this what you are asking?

"Eric Lawrence [MSFT]" <e_********@hotmail.com> wrote in message
news:em**************@tk2msftngp13.phx.gbl...
Does your application have permission to write to the filesystem?

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no

rights.

"Brent Burkart" <Br***********@wvmb.com> wrote in message
news:Oz**************@TK2MSFTNGP12.phx.gbl...
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. Can anyone point out my problem.

Thanks so much

objImage = objImage.FromFile(Server.MapPath(strFilename))
If objImage.Width > objImage.Height Then 'portrait

shtWidth = 350

' Work out a proportionate height from width

shtHeight = objImage.Height / (objImage.Width / shtWidth)

Else 'landscape

shtHeight = 370

' Work out a proportionate width from height

shtWidth = objImage.Width / (objImage.Height / shtHeight)

End If

' Create thumbnail

objThumbnail = objImage.GetThumbnailImage(shtWidth, _

shtHeight, Nothing, System.IntPtr.Zero)

' Send down to client

Response.ContentType = "image/jpeg"

objThumbnail.Save(Path.Combine(Server.MapPath(strP ath), strFilename2 &

"2"),
Imaging.ImageFormat.Jpeg)

ProductImage.ImageUrl = strFilename2

objImage.Dispose()

objThumbnail.Dispose()



Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.