473,326 Members | 2,010 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,326 software developers and data experts.

image resizing

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
3 2048
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Jim | last post by:
I've heard that resizing images through PHP (either GD2 or ImageMagick) is a processor intensive exercise. I'm setting up a site where users will be uploading up to 10 images along with the details...
6
by: bissatch | last post by:
Hi, I have a collection of images stored in a DB. They are there for the purpose of a news system. When the user views the homepage it will diplay cropped versions of the news where the user...
3
by: Zahid Khan | last post by:
I need little help in my situation. I am reading a graphic file (jpg) from disk and then resizing it and save resized image. What happens, it gets blured, I want to retain same quality so that...
10
by: David W. Simmonds | last post by:
I have a DataList control that has an Image control in the ItemTemplate. I would like to resize the image that goes into that control. I have a series of jpg files that are full size, full...
8
by: berkshire | last post by:
Hi, Anyone know of a script out there that can resize images and not sacrifice image quality? I've been using phpthumb (http://phpthumb.sourceforge.net/) but when compared to an image resized...
9
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...
9
by: kombu67 | last post by:
I'm reading a series of images from a MS SQL table and saving them to directory. These are staff ID pictures from our security card app. Once I've extracted the ID photo from the security app to...
10
by: mishrarajesh44 | last post by:
hii all, I am facing a problem currently.. i have a script for image uploading and resizing.. the image uploading takes place properly for every size images.. but, the resizing works for...
11
by: shapper | last post by:
Hello, I am displaying an image on a few pages. The image size is 50 px height and 50 px width. In some pages I need the image to be 30x30 px in others 40x40 px and in others 50x50px. Can I...
14
anfetienne
by: anfetienne | last post by:
hi.....i have this script (below #1) that is linked to another php file SimpleImage.php (#2) im trying to get it to work on my uploaded images but it keeps coming up errors.....i haven't altered...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.