Results 1 to 4 of 4

Thread: GD Overlay

  1. #1
    4x4
    Join Date
    Oct 2004
    Posts
    1,043

    GD Overlay

    I've never worked with the GD Library only ImageMagick, and am getting into using the GD now especially for my video sites where I take the first frame and create a thumbnail. I've already got it doing that, the next step is I want to overlay another image on top of my new thumbnail, and save it. (I want to put the PLAY arrow like YouTube has so people know to click the image to play the video.)

    What GD function would I use to overlay an image on another?

    Oh, and while we are on it, does anyone have the play arrow in PSD already

    -Todd

  2. #2
    Administrator Chris's Avatar
    Join Date
    Feb 2003
    Location
    East Lansing, MI USA
    Posts
    7,055
    Can't help you, but I just wanted to say I like GD over ImageMagick simply because GD usually is already installed in a standard way on most servers, or can easily be turned on, ImageMagick notsomuch.
    Chris Beasley - My Guide to Building a Successful Website[size=1]
    Content Sites: ABCDFGHIJKLMNOP|Forums: ABCD EF|Ecommerce: Swords Knives

  3. #3
    Registered Xander's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    263
    I put together the example below from the code at http://db.org/demo/2003/02/14/scale-and-overlay/. Hope its what you were looking for.

    PHP Code:
    <?php

        $overlay 
    'overlay.png';    //image to overlay i.e. arrow
        
    $origimg 'orig.png';        //image having the arrow added

        
    $trans_r 255;
        
    $trans_g 255;
        
    $trans_b 255;

        if(!
    $overlay imagecreatefrompng($overlay)) {
            
    $error 'error opening overlay image';
            exit;
        }

        
    $orig imagecreatefrompng($origimg);            

        
    $orig_x imagesx($orig);
        
    $orig_y imagesy($orig);
        
    $overlay_x imagesx($overlay);
        
    $overlay_y imagesy($overlay);
        
    $image_x $orig_x;
        
    $image_y $orig_y;

        
    $offset_x 0;
        
    $offset_y 0;

        
    $image imagecreatetruecolor($image_x$image_y);
        
    imagecopyresampled($image$orig0000$image_x$image_y$orig_x$orig_y);

        
    imagecolortransparent($overlayimagecolorallocate($overlay$trans_r$trans_g$trans_b));
        
    imagecopymerge($image$overlay$offset_x$offset_y00$overlay_x$overlay_y99);

        
    imagepng($image'over.png');


    ?>

    <html>
    <body>
    Overlayed image:<br />
    <img src = "over.png">
    </body>
    </html>

  4. #4
    4x4
    Join Date
    Oct 2004
    Posts
    1,043
    Thanks, I'll give it a shot.


    Side Note: I fail to see how GD is faster than ImageMagick having to do so many lines of code

Bookmarks

Posting Permissions

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