Watermark Demo

Click refresh to see the watermark move.

This is a watermark

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/ollie.JPG");
$watermark imagecreatefrompng("images/copyright_dxanderdev_wm.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 -->




<?php

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

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