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 3 of 3
  1. #1
    Regular Coder Ludatha's Avatar
    Join Date
    Jan 2008
    Posts
    250
    Thanks
    51
    Thanked 5 Times in 5 Posts

    Transparent watermark

    http://ludatha.com/test/watermark/

    This script displays a watermark in the center of any given image, the problem is, it doesn't seem to keep the transparency from the previous image.

    The image I want to use as a watermark is
    http://ludatha.com/themes/ludatha/images/logo.png


    Does anyone know how to keep the transparency?

    This is the code

    PHP Code:
    function watermark(){
            
    header('content-type: image/jpeg');
                
            
    $watermark imagecreatefrompng('http://ludatha.com/themes/ludatha/images/logo.png');  
            
    $watermark_width imagesx($watermark);  
            
    $watermark_height imagesy($watermark);  
            
    $image imagecreatetruecolor($watermark_width$watermark_height);  
            
    $image imagecreatefromjpeg('http://fc05.deviantart.com/fs49/i/2009/218/6/7/Emma_1_by_ludatha.jpg');  
            
    $size getimagesize('http://fc05.deviantart.com/fs49/i/2009/218/6/7/Emma_1_by_ludatha.jpg');  
            
    $dest_x = ($size[0] /2) - ($watermark_width 2);
            
    $dest_y = ($size[1] /2) - ($watermark_height 2);
            
    imagecopymerge($image$watermark$dest_x$dest_y00$watermark_width$watermark_height100);  
            
    imagejpeg($image);
            
    imagedestroy($image);
            
    imagedestroy($watermark);
        } 
    Last edited by Ludatha; 11-01-2009 at 01:01 AM.

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,538
    Thanks
    8
    Thanked 1,093 Times in 1,084 Posts
    Without knowing much about your PNG image, 24 bit, 8 bit, transparency?
    ... try changing the 100 to 20 ... see below ...

    imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 20);

  • #3
    Regular Coder Ludatha's Avatar
    Join Date
    Jan 2008
    Posts
    250
    Thanks
    51
    Thanked 5 Times in 5 Posts
    Quote Originally Posted by mlseim View Post
    Without knowing much about your PNG image, 24 bit, 8 bit, transparency?
    ... try changing the 100 to 20 ... see below ...

    imagecopymerge($image, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, 20);
    http://ludatha.com/test/watermark/
    I did that, but the background still isn't transparent...

    I think it's 24bit

    EDIT: I found this, http://drupal.org/node/80369
    PROBLEM SOLVED
    Last edited by Ludatha; 11-01-2009 at 01:01 AM.


  •  

    Posting Permissions

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