PDA

View Full Version : image aspect ratio



o0O0o.o0O0o
Dec 16th, 2008, 12:30 AM
hi ,


Currently i use height and width attribute to fit the image in fixed with box. Its working good if the image is square .

is there any way to fix the aspect ratio of the image so that if the height is reduced then correspoding width also reduces to make the image display natural

_Aerospace_Eng_
Dec 16th, 2008, 12:33 AM
You can set only one dimension and the other dimension will size proportionately. So just set the width or the height but not both.

o0O0o.o0O0o
Dec 16th, 2008, 01:28 AM
I will try that and see how it goes . Thanks

o0O0o.o0O0o
Dec 16th, 2008, 02:05 AM
I have only specified the height , now images are working fine.
But the problem comes if the image has more width than height , then images gets increased to height and width becomes also very long


Is there any way to find first whether width is greater or height and then adjust only one

_Aerospace_Eng_
Dec 16th, 2008, 06:13 AM
You can use javascript or php. PHP would be better as the it doesn't require that JS is enabled and there is no delay. You would need to pass the image filename to getimagesize. Set getimagesize to a variable called $list then you can compare $list[0] and $list[1].

Read the php manual on how to use getimagesize and what it contains.