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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resizing images from the web (keep correct ratio)

Status
Not open for further replies.

GiddyRob

Programmer
Aug 25, 2005
37
GB
Hi,

if I have an image on my website coming from a different location:
src="
How do I get the images width or height, depending which is greater, to be no more than 120px. Basically I want the image to have the correct ratio so that if the original height is greater than the width, the heights value will be 120px and the width is less.

Regards

Rob Shillito
 
To get the dimensions of an image read faq216-5781. You can then apply the relevant height and widths accordingly.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
I am fairly new to javascript but I dont really think thats what I want.

Thanks anyhow :)

Does anyone else have any ideas?

Cheers

Rob
 
In what way is it not what you want?
The script ca8msm pointed you to will read an image file and return it's height and width values which is the first step you need to take in order to resize it. You will of course have to compute the new dimensions to get them to be of the correct ratio but you have to know the dimensions first.

The script as shown uses a user interface to select the image to check just as an example. You can just as easily hardcode the path/filename of the image to test or pass it in as a variable and return the dimensions.

If that is not what you need then you need to re-define what you are asking for.


Stamp out, eliminate and abolish redundancy!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top