image resizing

B

Brent Burkart

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(strPath), strFilename2 & "2"),
Imaging.ImageFormat.Jpeg)

ProductImage.ImageUrl = strFilename2

objImage.Dispose()

objThumbnail.Dispose()
 
E

Eric Lawrence [MSFT]

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.
 
B

Brent Burkart

I am not sure. I have given my aspnet accounts permission to the folders.
Is this what you are asking?
 
E

Eric Lawrence [MSFT]

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top