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 8 of 8
  1. #1
    Regular Coder
    Join Date
    Nov 2005
    Posts
    225
    Thanks
    2
    Thanked 0 Times in 0 Posts

    How to resize images automatically

    Hello,

    I have a dating site. When members upload their images, how do I resize the images to be 300px width and let the height automatically?

    some images are large so they load too slow.

    Can you please help?

    Thanks,

    Jenny.

    p.s.

    Here is the upload image code block:
    Code:
    <input name = "image_<? echo $i;?>" type = "text" id="image_<? echo $i;?>" value="<? echo $image[$i];?>" size="20" readOnly > 
                  <input   type=BUTTON name=btn_name<? echo $i;?> value="Upload" onClick=attachment('image_<? echo $i;?>')>

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Look into the GD library, specifically imagecopyresampled().

  • #3
    Regular Coder
    Join Date
    Nov 2005
    Posts
    225
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thank you, I'll try that.

  • #4
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,517
    Thanks
    114
    Thanked 110 Times in 109 Posts
    You can not say you know how to do something, until you can teach it to someone else.

  • #5
    Regular Coder
    Join Date
    Nov 2005
    Posts
    225
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thanks.

  • #6
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,517
    Thanks
    114
    Thanked 110 Times in 109 Posts
    did it work?
    You can not say you know how to do something, until you can teach it to someone else.

  • #7
    Regular Coder
    Join Date
    Nov 2005
    Posts
    225
    Thanks
    2
    Thanked 0 Times in 0 Posts
    I tried to create a file called "resizeimg.php" and put your code in.
    Then, I put this:
    <?PHP
    $dimensions_of_thumb=get_dims('http://domain/imagefolder/,200px);
    $x_dimension=$dimensions_of_thumb[0];
    $y_dimension=$dimensions_of_thumb[1];
    ?>

    on the top of the file that member upload images when they register, but nothing happened. I only change to imagefolder/ because I want to resize all images in that folder, but it does not execute.

    I placed on the top of this page:
    <input name = "image_<? echo $i;?>" type = "text" id="image_<? echo $i;?>" value="<? echo $image[$i];?>" size="20" readOnly >
    <input type=BUTTON name=btn_name<? echo $i;?> value="Upload" onClick=attachment('image_<? echo $i;?>')

    Please advice.
    Thanks.

  • #8
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,517
    Thanks
    114
    Thanked 110 Times in 109 Posts
    Sorry for the late response.

    I'm a bit confused as to exactly what you have done. Any chance I can see all the code?
    You can not say you know how to do something, until you can teach it to someone else.


  •  

    Posting Permissions

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