Watermark Demo

Click refresh to see the watermark move.

This is a watermark

My two files:

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 imagecreatefrompng("../../images/theflow.png");
$watermark imagecreatefrompng("../../images/cool.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);
?>