Mahmoud's 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/john-lennon.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);
?>