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 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Apr 2011
    Posts
    6
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question Layering Two Images

    All i need is some PHP + GD Script which takes two image URLS and Two Coordinates. What I want it to do with those is join the two images at those coordinates.
    The effect I would like is for it to take the address of an armour and a sword and make the person (armour) hold the sword

  • #2
    New Coder
    Join Date
    Feb 2007
    Posts
    86
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Try this:

    PHP Code:
    <?php 
    # background image
    $image1 imagecreatefromjpeg('comp-bg.jpg');
    imagealphablending($image1true);

    # image to composite
    $image2 imagecreatefromjpeg('comp-2.jpg');
    $width imageSX($image2);
    $height imageSY($image2);

    # position your image, replacing 220, 315, with 0, 0,
    # will place your image to the top left corner
    imagecopy($image1$image222031500$width$height);

    imagecolorallocate($image1255255255);

    # output to browser
    header("Content-type: image/jpeg");
    imagejpeg($image1);

    # write image to directory
    imagejpeg($image1"composited.jpg");

    # free server memory
    imagedestroy($image1); 
    imagedestroy($image2); 
    ?>
    If you can use ImageMagick by the command line, take a look at this:

    http://www.lingolinda.com/2008/scrip...mageMagick.php
    Last edited by Jinxy; 06-02-2011 at 05:09 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
    •