Watermark Demo

Click refresh to see the watermark move.

This is a watermark

You will need two files like the following:

However, use your own images -- not the ones provided above.

Please note, the watermark image has to be transparent.

Also please note where the images should reside (i.e., images directory).



SLAVE CODE FOLLOWS

<?php    // combine two images (i.e., jpg/png) to create a watermark

    // NOTE: The watermark image must be smaller than the target image
    // and the background of the watermark image has to be transparent

    // get the images from files
    
$image imagecreatefromjpeg("images/baby.jpg");
    
$watermark imagecreatefrompng("images/copyright.png");

    
// get sizes
    
$osx imagesx($image);
    
$osy imagesy($image);
    
$wsx imagesx($watermark);
    
$wsy imagesy($watermark);

    
// create a random placement for watermark
    
switch (rand(1,5))
          {
          case 
1:  // center
          
imagecopy($image$watermark, ($osx-$wsx)/2, ($osy-$wsy)/200$wsx$wsy);
          break;
  
          case 
2:  // top-left
          
imagecopy($image$watermark,0000$wsx$wsy);
          break;  

          case 
3:  // bottom-left
          
imagecopy($image$watermark0, ($osy-$wsy), 00$wsx$wsy);
          break;  
  
          case 
4:  // top-right
          
imagecopy($image$watermark, ($osx-$wsx), 000$wsx$wsy);
          break;  
  
          case 
5:  // bottom-right
          
imagecopy($image$watermark, ($osx-$wsx), ($osy-$wsy), 00$wsx$wsy);
          break;  
          }
    
    
// set the header for the image        
    
header("Content-type: image/png");
    
imagepng($image);
    
imagedestroy ($image); 
?>
 

CODE FOLLOWS

<?php
    
include('includes/header.php');
?>

    <h1>
        Watermark Demo
    </h1>

    <p>
        Click refresh to see the watermark move.
    </p>

    <img src="watermark.php" alt="This is a watermark"> <!-- this is it -->

    <p>
        You will need two files like the following:
    </p>

    <ul>
        <li>
            <a href="images/baby.jpg">baby.jpg (as found here</a>)
        </li>
        <li>
            <a href="images/copyright.png">copyright.png (as found here</a>)
        </li>
    </ul>

    <p>
       However, use your own images -- not the ones provided above.
    </p>

    <p>
        Please note, the watermark image has to be transparent.
    </p>

    <p>
        Also please note where the images should reside (i.e., images directory).
    </p>

<?php

    
// list code for slave routine         
    
echo('<hr><br>SLAVE CODE FOLLOWS<br><br>');
    
highlight_file('watermark.php');

    include(
'includes/footer.php');
?>