I am trying to find the image aspectratio,so width/height
gives the aspect ratio of any image. But i want to set the image width and height like mozilla sets width and height of an image when i set max-width
or max-height
to somevalue
.
How to do this calculation to find width and height of an image with correct aspect ratio?
new_width = width/height*user_definedwidth;
like this, but i want to calculate both width and height for any image?
How mozilla sets both width and height with aspect ratio when max-width or max-height have set.
I need to show any user uploaded image with correct aspect ratio but large size images need to be resized.
<img src="http://hdcomputerwallpaper.com/wp-content/uploads/2013/12/Puppy-images.jpg" style='max-width:200px;'/>