Results 1 to 2 of 2
  1. #1
    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)

  2. #2
    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

  1. Image resizing on website
    By ruts in forum Programming Discussion
    Replies: 7
    Last Post: 09-02-2009, 11:20 AM
  2. got some problems resizing an image...
    By fm78 in forum Web Design and Content
    Replies: 3
    Last Post: 06-20-2008, 10:47 AM
  3. RESIZING a PrntScrn Image
    By melian9102 in forum Web Design and Content
    Replies: 2
    Last Post: 05-21-2005, 08:46 PM
  4. automaticaly resizing an image so it fits ...
    By mmjulian in forum Web Design and Content
    Replies: 3
    Last Post: 05-20-2005, 07:43 PM
  5. image resizing
    By sasha in forum Programming Discussion
    Replies: 8
    Last Post: 06-02-2003, 08:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •