Solved

Image Adjustment

Posted on 2006-11-30
5
271 Views
Last Modified: 2010-04-06
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.

0
Comment
Question by:sohrabus
5 Comments
 
LVL 5

Expert Comment

by:dasmaer
ID: 18044551
To keep the dimensions of the original image you need to increase the size of the height as well as the width.

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
0
 
LVL 8

Expert Comment

by:tncbbthositg
ID: 18049124
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
0
 
LVL 5

Expert Comment

by:cwickens
ID: 18055679
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.
0
 

Author Comment

by:sohrabus
ID: 18058874
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.
0
 
LVL 8

Accepted Solution

by:
tncbbthositg earned 250 total points
ID: 18061107
Then create the image so that it looks good at 1024.  It'll look better resized down than resized up.  The problem is that big images take a long time to download.

TNC
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
It's sometimes a bit tricky to use date functions in Oracle BPEL. I'll explain quickly how you can add N days to the current date. In a BPEL process this can be useful, and you can adapt it to fit your needs. First of all, let's see how to add 1 …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now