Click to See Complete Forum and Search --> : Image Resize With Locked Aspect Ratio?


mouser28
04-20-2003, 11:48 PM
Aloha,

I was playing around with one of the BG effect scripts in the library called Full Size Image, which autodetects the browser window size and resizes an image to fill the window.

http://javascript.internet.com/bgeffects/full-size-image.html

It works great, but I was wondering if it could be modified to resize the image with a locked aspect ratio (same ratio of height X width) but still maximize the size of the image in the window? I don't know enough abot Java to mess with the code successfully to get this result.

-Mike

Mr J
04-21-2003, 04:55 AM
If you are going to maximise to the window sizes you cannot keep the original ratios without having white space added onto the smallest dimension.

The ratio for a 800 x 600 window is 1.33 : 1 so if your image was say height 100 x width 200 expanding until the width fitted the screen width would give you an image size of height 400 x width 800 so you would have 100 above and below the image of white space.

I think
:(

mouser28
04-21-2003, 11:44 AM
Thank you for your response...

Yes, I expected white space, that's not a problem. I actually tweaked the code by just removing the width tag in the Javascript and it actually worked. It's pretty slick, at least if you use a high-res image.

So, problem solved! :D

-Mike