Connecting Tech Pros Worldwide Help | Site Map

The proportionate to the size of the image scaling window

Peter May
Guest
 
Posts: n/a
#1: Sep 3 '08
Hi.

I know the dimensions area visible on the screen and I would like to
picture that there put dynamically, match its size to the window, while
retaining the proportions of course.

For example:

Screen area visible: 1280x589
The picture size: 3008x2000

What use a mathematical formula to convert the size of the image, which
adjust it to a visible area on the screen?

--
Peter
GArlington
Guest
 
Posts: n/a
#2: Sep 3 '08

re: The proportionate to the size of the image scaling window


On Sep 3, 9:34*am, Peter May <peter....@poczta.fmwrote:
Quote:
Hi.
>
I know the dimensions area visible on the screen and I would like to
picture that there put dynamically, match its size to the window, while
retaining the proportions of course.
>
For example:
>
Screen area visible: * *1280x589
The picture size: * * * 3008x2000
>
What use a mathematical formula to convert the size of the image, which
adjust it to a visible area on the screen?
>
--
Peter
Is not it obvious? All you have to do is to think about it...
1) Calculate scaling scaleRatio = MIN((scrHeight / imageHeight),
(scrWidth / imageWidth));
You will probably want to do following two steps ONLY when scaleRatio
< 1 i.e. image was too big, you will NOT want to show the image BIGGER
than the original because of loss of quality...
2) Calculate new image width = imageWidth * scaleRatio ;
3) Calculate new image height = imageHeight * scaleRatio ;
Stevo
Guest
 
Posts: n/a
#3: Sep 3 '08

re: The proportionate to the size of the image scaling window


Peter May wrote:
Quote:
Hi.
>
I know the dimensions area visible on the screen and I would like to
picture that there put dynamically, match its size to the window, while
retaining the proportions of course.
>
For example:
>
Screen area visible: 1280x589
The picture size: 3008x2000
>
What use a mathematical formula to convert the size of the image, which
adjust it to a visible area on the screen?
Is there a reason you can't just let the browser work it out for you?
Something like this for example:

<img width="100%" height="100%" border="0" src="path_to_your_img">

You may or may not want to put that inside a DIV that's sized to 100%,
like this:

<div style="width:100%;height:100%">
<img tag goes here>
</div>


As you resize the browser, the div and img would auto-resize with it.
Peter May
Guest
 
Posts: n/a
#4: Sep 3 '08

re: The proportionate to the size of the image scaling window


GArlington pisze:
Quote:
On Sep 3, 9:34 am, Peter May <peter....@poczta.fmwrote:
Quote:
>Hi.
>>
>I know the dimensions area visible on the screen and I would like to
>picture that there put dynamically, match its size to the window, while
>retaining the proportions of course.
>>
>For example:
>>
>Screen area visible: 1280x589
>The picture size: 3008x2000
>>
>What use a mathematical formula to convert the size of the image, which
>adjust it to a visible area on the screen?
>>
>--
>Peter
>
Is not it obvious? All you have to do is to think about it...
Not everything is obvious, such as it appears.
Quote:
1) Calculate scaling scaleRatio = MIN((scrHeight / imageHeight),
(scrWidth / imageWidth));
You will probably want to do following two steps ONLY when scaleRatio
< 1 i.e. image was too big, you will NOT want to show the image BIGGER
than the original because of loss of quality...
2) Calculate new image width = imageWidth * scaleRatio ;
3) Calculate new image height = imageHeight * scaleRatio ;
After just missing me a simple mathematical formula. Such guidance. Your
solution is what i'm looking for. Thank you.

--
Peter
Peter May
Guest
 
Posts: n/a
#5: Sep 3 '08

re: The proportionate to the size of the image scaling window


Stevo pisze:
Quote:
Peter May wrote:
Quote:
>Hi.
>>
>I know the dimensions area visible on the screen and I would like to
>picture that there put dynamically, match its size to the window,
>while retaining the proportions of course.
>>
>For example:
>>
>Screen area visible: 1280x589
>The picture size: 3008x2000
> What use a mathematical formula to convert the size of the image,
>which adjust it to a visible area on the screen?
>
Is there a reason you can't just let the browser work it out for you?
Something like this for example:
>
<img width="100%" height="100%" border="0" src="path_to_your_img">
>
You may or may not want to put that inside a DIV that's sized to 100%,
like this:
>
<div style="width:100%;height:100%">
<img tag goes here>
</div>
>
>
As you resize the browser, the div and img would auto-resize with it.
Sure, that could use CSS. But you have to set the max-width: 100%,
max-height: 100%, while center <divvertically and horizontally. And
this happens in different ways.

--
Peter
Closed Thread