Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resize Large Images

Status
Not open for further replies.

hedidit

Technical User
Jul 21, 2005
142
GB
Hi all,

I'm using ASP to upload images to my website, problem is some of the images are very large (they're from digital camreas).

The images are shown in a popup window from ym site but some of the larger images don't fit in the popup, i tried setting the width of the image on the page so that they all fitted in BUT some of the pictures are smaller and so are stretched out!

Can anyone tell me how to resize images to fit on the page available?

Cheers in advance

 
In your popup window, assuming the images are in an <img> tag, set the width and height properties in the tag itself, the image will stretch and shrink to fit the size specified:

Code:
<img src="picture.gif" [!]width="13"[/!] [!]height="20"[/!] alt="" />

This will work as is if all the images have the same dimensions, if they don't you can still make it work adding some ASP.

<.

 
If you want to get fancy you can detect the image size and then calculate the reduced dimensions for your popup.
There is a FAQ by BillyRayPreachersSon on detecting the image size from client-side script. There are ways of accomplishing this server-side though I have not seen code to do it.

Once you know the images dimensions you can calculate the best fit dimensions for the reduced image without distorting it's aspect.


At my age I still learn something new every day, but I forget two others.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top