Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: Image Resizing

  1. #1
    New Coder
    Join Date
    Mar 2008
    Location
    A large mitten
    Posts
    34
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Image Resizing

    I would like to resize images, but I do not want to save them resized, I would prefer changing the size by using the <img src='' height='%' width='%' />. I have an image uploader that displays the user's uploaded images, and I don;t want a 500x500 image in a 900 pixel wide space with 2 other images sharing the row.

    Is there an easy way to do this?

  • #2
    New Coder
    Join Date
    Aug 2008
    Posts
    90
    Thanks
    5
    Thanked 3 Times in 3 Posts
    php is a server side language so you couldnt do that in php, but you should get more help in the javascript forum try there. If u want to store the final size, u could just put that in a table thru php but otherwise php isn't your friend

  • #3
    Regular Coder UrbanTwitch's Avatar
    Join Date
    Apr 2006
    Posts
    485
    Thanks
    44
    Thanked 1 Time in 1 Post
    Google Ajax Image Resize.
    Formerly MysticScript

    6+ years club

  • #4
    New Coder
    Join Date
    Mar 2008
    Location
    A large mitten
    Posts
    34
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Well, not exactly...

    I have used:

    PHP Code:
    list($width$height$type$attr) = getimagesize($img); 
    Then between that code and what's below, some code that will take the oversized $width, $height and try to make then make a new width and height that allows the image to keep the same shape, but be correctly sized.

    Then...
    PHP Code:
    if($new_width != $width)
    {
        
    $width $new_width;
    }
    else
    {
        
    $width $width;
    }

    if(
    $new_height != $height)
    {
        
    $height $new_height;
    }
    else
    {
        
    $height $height;
    }

    $img_code "<img src='$img' alt='User Image' width='$width' height='$height' />";

    echo 
    $img_code
    The trouble I am having is getting it so that it keeps it the same shape, but can resize it to be as big as it possibly can without streching the page.


  •  

    Posting Permissions

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