Results 1 to 2 of 2
Thread: Resizing an Image Proportionally
-
12-09-2009, 03:22 PM #1Junior Guru Wannabe
- Join Date
- Sep 2004
- Location
- CA
- Posts
- 59
Resizing an Image Proportionally
Can anyone help me with this. I have a page setup that will display information submitted by users. Along with this they can include a link to an outside image.
I'd like to automatically display the image proportionally down to a 350 width or a 350 height. I don't want it to display the image as 350x350, but force either the height or width to 350 and proportionally shrink the other width or height with it.
Does anyone know what this would be called? I've tried searching Google, but there's too many details to include it all. If anyone has some samples or links I'd be grateful. Thanks!
(Another useful, but I could live without, would be something that required the width or height to be equal to 350 or higher)
-
12-09-2009, 04:19 PM #2Retired Moderator
- Join Date
- May 2004
- Location
- Pflugerville, TX
- Posts
- 11,231
Here's a variation on a script I wrote a while back. It will resize any image on the screen that's more than the value you choose. It can be modified to specifically resize only a certain object instead, if you need it that way.
I didn't test it after modifying it, but it should work...
Code:<script type="text/javascript"> var MaxWidth = 350; allPics = document.getElementsByTagName('img'); for (i=0 ; i<allPics.length ; i++) { if(allPics[i].offsetWidth > maxWidth) { allPics[i].style.width = maxWidth+'px'; allPics[i].style.height = ((allPics[i].offsetHeight * maxWidth) / allPics[i].offsetWidth) + 'px'; } } </script>
Studio1337___̴ı̴̴̡̡̡ ̡͌l̡̡̡ ̡͌l̡*̡̡ ̴̡ı̴̴̡ ̡̡͡|̲̲̲͡͡͡ ̲▫̲͡ ̲̲̲͡͡π̲̲͡͡ ̲̲͡▫̲̲͡͡ ̲|̡̡̡ ̡ ̴̡ı̴̡̡ ̡͌l̡̡̡̡.__Web Design
Similar Threads
-
Image resizing on website
By ruts in forum Programming DiscussionReplies: 7Last Post: 09-02-2009, 11:20 AM -
got some problems resizing an image...
By fm78 in forum Web Design and ContentReplies: 3Last Post: 06-20-2008, 10:47 AM -
RESIZING a PrntScrn Image
By melian9102 in forum Web Design and ContentReplies: 2Last Post: 05-21-2005, 08:46 PM -
automaticaly resizing an image so it fits ...
By mmjulian in forum Web Design and ContentReplies: 3Last Post: 05-20-2005, 07:43 PM -
image resizing
By sasha in forum Programming DiscussionReplies: 8Last Post: 06-02-2003, 08:47 PM