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
  1. #1
    Regular Coder
    Join Date
    Dec 2009
    Posts
    240
    Thanks
    7
    Thanked 0 Times in 0 Posts

    How Can I Set The Images Size Automatically?

    Alright Guys

    I am wondering if I can automatically set the size on image that I am uploading please?

    Let me try and explain..

    I am using a membership script on my website.. Under the admin settings, add product page, it allows me to add an image to be displayed.. This is done via a text box...

    Then the image is display on this page with the rest of the product details.. http://www.digitalresellersvault.com..._Resale_Rights

    As you can tell I have an image, but the image is way much bigger.. I am wondering if there is anyway that I can write some code that tells image to be a certain size in a particular section? It doesnt matter on the size of the image that you have uploaded to the server..

    Hope you understand

  • #2
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    PHP can do all sorts of image manipulation.


    http://php.net/manual/en/book.image.php




    --------------------------------
    Leonard Whistler

  • #3
    Regular Coder
    Join Date
    Dec 2009
    Posts
    240
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Len Whistler View Post
    PHP can do all sorts of image manipulation.


    http://php.net/manual/en/book.image.php




    --------------------------------
    Alright Len

    Which one am I suppose to be looking at? There is one for copy an image then resize it.. Is that the one? I cant see one that say resize image

  • #4
    Senior Coder Len Whistler's Avatar
    Join Date
    Jul 2002
    Location
    Vancouver, BC Canada
    Posts
    1,323
    Thanks
    26
    Thanked 100 Times in 100 Posts
    I recommend you go through the links on that page and scroll down for code examples. This one will display the image at half size:


    PHP Code:
    <?php
    // File and new size
    $filename 'test.jpg';
    $percent 0.5;

    // Content type
    header('Content-type: image/jpeg');

    // Get new sizes
    list($width$height) = getimagesize($filename);
    $newwidth $width $percent;
    $newheight $height $percent;

    // Load
    $thumb imagecreatetruecolor($newwidth$newheight);
    $source imagecreatefromjpeg($filename);

    // Resize
    imagecopyresized($thumb$source0000$newwidth$newheight$width$height);

    // Output
    imagejpeg($thumb);
    ?>
    When you find something that's close to what you want you then modify it for your needs.
    Leonard Whistler


  •  

    Posting Permissions

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