sohrabus
asked on
Image Adjustment
Hi,
I'm using asp.net 1.1
I have an Image and
Image width is 468
My Screen width is 800
How can I adjust this image so that it fit to the size of Screen (i.e. 800) without loosing its effects.
Image Adjustment accoring to screen width.
Awaiting ur kind guidance.
I'm using asp.net 1.1
I have an Image and
Image width is 468
My Screen width is 800
How can I adjust this image so that it fit to the size of Screen (i.e. 800) without loosing its effects.
Image Adjustment accoring to screen width.
Awaiting ur kind guidance.
How are you going to get the screen width? I think this is a job for javascript.
you should use:
<img src="afile.jpg" onload="resize(this);" />
Then, you should have this in between your head tags:
<script type="text\javascript">
function resize(oTarget)
{
oTarget.height *= window.innerWidth / oTarget.width;
oTarget.width = window.innerWidth;
}
</script>
Or something like that.
TNC
you should use:
<img src="afile.jpg" onload="resize(this);" />
Then, you should have this in between your head tags:
<script type="text\javascript">
function resize(oTarget)
{
oTarget.height *= window.innerWidth / oTarget.width;
oTarget.width = window.innerWidth;
}
</script>
Or something like that.
TNC
what do you mean by "without losing it's effects"? if you mean becoming pixelated, that will happen unless the image is a vector image. this will become even more evident if there is a user who visits the site with a higher screen resolution and views the page at say 1400x1050.
ASKER
Dear boses,
Thanks for ur kind support.
I'm able to fit IMAGE according to screen width. whether it its width is 800 px or 1024 px.
BUT if IMAGE of 468 px is STRECHED to 800 px its effects (resolution) gets disturb. it does not look good.
Dear cwickens,
without losing it's effects - I want my Image look good whether width is 468 px, 800 px or 1024 px.
Awiting ur kind advice.
Thanks for ur kind support.
I'm able to fit IMAGE according to screen width. whether it its width is 800 px or 1024 px.
BUT if IMAGE of 468 px is STRECHED to 800 px its effects (resolution) gets disturb. it does not look good.
Dear cwickens,
without losing it's effects - I want my Image look good whether width is 468 px, 800 px or 1024 px.
Awiting ur kind advice.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In your case you increase width from 468 to 800, which is a mulitplier of 1.709401709 (800/468). So you need to increase your height by the same value:
new_height = old_height * (new_width/old_width)
You then put these values into an img tag like: <img src="afile.jpg" width="<%=new_width%>" height="<%=new_height%>">
Hope this is what you're looking for.
D