Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

About image resolution

Status
Not open for further replies.

abhi910

Programmer
Jul 14, 2006
9
I wanted to check if anyone is aware of any javascript library which can be used to preserve the aspect ratio of images. My requirement is that whatever dimensions the original image has, I need to be able to resize it (so that it fits my page) without losing its quality.

Thanks is advance
A
 
Can't you just inspect the [tt].width[/tt] and [tt].height[/tt] properties of the image and make sure that whatever factor you multiply one by, that you multiply the other by it as well?

So if you wanted the picture to be a maximum of either 800px wide or 600px high, you would look at the picture, think "ah, the longest side of this 50 pixel high by 200 pixel wide image is it's width... to hit my maximum, I'll multiply the width by 3, then multiply the height by 3 as well to make sure I don't lose the aspect ratio"

[sub]Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
[/sub]

Enable Apps
 
I am doing that currently, but the issue is that while doing so, the image becomes grainy and i lose its quality. I was just wondering how these socail community sites manage the image quality. In some pages the person's image is small, in some it is big, still the image looks good.
 
I'd say they start with a big image and scale down. There's no way (certainly not in JS) that you could increase the size of an image without losing quality.

[sub]Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
[/sub]

Enable Apps
 
Ok, thanks! I think i need to create different sized images using some other backend technique.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top