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: Resize Image

  1. #1
    New Coder
    Join Date
    Sep 2012
    Posts
    21
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Resize Image

    I have a page that merges two pictures into one using the code below. I am trying to rezise the $src image. At the minute the last two numbers in imagecopymerg resizes what is displayed but it shows only part of the image and doesn't resize the image, for example it would show the top corner of the image.

    Code:
    <?php
    $dest = imagecreatefrompng('polayoloright.png');
    $src = imagecreatefromjpeg('tiffany_alvord_heart_2bg9s7p.sized.jpg');
    imagealphablending($dest, false);
    imagesavealpha($dest, true);
    $src = imagecreatetruecolor(50,50);
    imagecopymerge($dest, $src, 1, 1, 0, 20, 50, 50, 100);
    header('Content-Type: image/png');
    imagepng($dest);
    imagedestroy($dest);
    imagedestroy($src);
    ?>

    I have tried adding the following. It resizes it but displays a black box, not the image.
    Code:
    $src = imagecreatetruecolor(50,50);
    Any ideas?

    Thanks

  • #2
    New Coder
    Join Date
    Oct 2012
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    This is how i resize my image. Try to implement this to your code.

    <?php
    include('SampleImage.php'); //file name
    $image = new SampleImage();
    $image->load('picture.jpg'); //image name
    $image->resize(250,400);
    $image->save('picture2.jpg');
    ?>

  • #3
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,309
    Thanks
    58
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    Quote Originally Posted by henryc06 View Post
    This is how i resize my image. Try to implement this to your code.

    <?php
    include('SampleImage.php'); //file name
    $image = new SampleImage();
    $image->load('picture.jpg'); //image name
    $image->resize(250,400);
    $image->save('picture2.jpg');
    ?>
    Thats not very helpful to the op is it. You;'ve included the code to use a class (in SampleImage.php) but not given them the code for that file. What do you expect them to do with it? It's useless.

    @penny White hat web design have a very good class with sample code on their website - I always recommend it as its very good:
    http://www.white-hat-web-design.co.u...ages-with-php/
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!

  • #4
    New Coder
    Join Date
    May 2012
    Posts
    50
    Thanks
    6
    Thanked 4 Times in 4 Posts
    And if you're not up to create this class yourself. TimThumb is an great option for resizing. TimThumb: http://www.binarymoon.co.uk/projects/timthumb/


  •  

    Posting Permissions

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