473,396 Members | 1,891 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,396 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 2050
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.