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 2002
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    gd image to watermark image?

    is there a method in gd to change an image into a watermark image?

    i'm wishing to create an automated process where and image would be automatically converted to 20% opacity against a white matte.
    seldom ruined but by myself

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    UK
    Posts
    577
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you want to iterate through the image pixel by pixel and then imagecopymerge a sampling over a plain white base

    PHP Code:
    <?php
    $resource 
    'whatever.jpg';
    $opacity 20;
    $siz getimagesize($resource);
    $basei imagecreatefromjpeg($resource);
    $newi imagecreatetruecolor($siz[0],$siz[1]);
    $whit imagecolorallocate($newi255255255);
    for(
    $dy 0$dy $siz[1]; $dy++)
     {
     for(
    $dx 0$dx $siz[0]; $dx++)
      {
      
    imagecopymerge($newi$basei$dx$dy$dx$dy11$opacity);
      }
     }
    imagedestroy($basei);
    imagejpeg($newi'folder/save.jpg'85);
    imagedestroy($newi);
    ?>
    fly typed so will probably parse bad, should point you in the right direction though.
    subnote - GD2 functions used.

    -------------
    edit - you wouldn't need to iterate really - lose the for loops and just use

    imagecopymerge($newi, $basei, 0, 0, 0, 0, $siz[0], $siz[1], $opacity);
    Last edited by Ökii; 03-24-2003 at 10:04 PM.
    Ökii - formerly pootergeist
    teckis - take your time and it'll save you time.

  • #3
    Regular Coder
    Join Date
    Dec 2002
    Posts
    109
    Thanks
    0
    Thanked 0 Times in 0 Posts

    :)

    THANK YOU, COOL PERSON!
    seldom ruined but by myself

  • #4
    New Coder
    Join Date
    Jan 2003
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Watermark

    This is very cool...

    But is there a way to embed the watermark on the top of the image, you know like to have a JPG with a watermark on the top...

    And also be able to control the quality and opacity based on the color that we don't want to be visible...

    Also I forgot I have GD. 1.6 so imagecreate() is what works not imagecreateTrueColor()

    Please help
    Any ideas?


  •  

    Posting Permissions

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