Who's good at maths?

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
SpaceshipSpaceship
Watch

adam_uk

Established Member
Impact
20
hey

i suck at maths big time and i got a problem

im making a image script for someone

if an image is wider than 700px the hole page distorts and looks crap

i can set the width and the height of the image easily but if i set the image width to 700 it looks like its been stretched because of the height

so what i need to do is to find out a ratio/scale/%age of the height to the width so the image wont look distored or stretched

and then im going to provide a link to the full size image...

anyone got any ideas?

thanks
adam
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Eg :

468 H
60 H

468 / 60 = 7.8

So your W should remain 7.8 times your H -

You'll need Both Actual Dimensions W = Width H = Height

Does this help ?
 
0
•••
yeah i know what to do. Lets say your max width is 300 px and somebody submits an image that is 600 px wide and 200 px high.

newWidth = maxWidth
newHeight = (maxWidth * originalHeight) / originalWidth


That should keep the images scaled
 
0
•••
thank you both


helped me alot B-)

works a treat :)
 
0
•••
Nice job, folks! :tu:

B-)
 
0
•••
Yay for solving problems! :D
 
0
•••
CatchedCatched

We're social

Escrow.com
Spaceship
Escrowly
CryptoExchange.com
Domain Recover
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back