Watermark Demo
Click refresh to see the watermark move.
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_yoda1.jpg");
$watermark = imagecreatefrompng("images/");
// 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)/2, 0, 0, $wsx, $wsy);
break;
case 2: // top-left
imagecopy($image, $watermark,0, 0, 0, 0, $wsx, $wsy);
break;
case 3: // bottom-left
imagecopy($image, $watermark, 0, ($osy-$wsy), 0, 0, $wsx, $wsy);
break;
case 4: // top-right
imagecopy($image, $watermark, ($osx-$wsx), 0, 0, 0, $wsx, $wsy);
break;
case 5: // bottom-right
imagecopy($image, $watermark, ($osx-$wsx), ($osy-$wsy), 0, 0, $wsx, $wsy);
break;
}
// set the header for the image
header("Content-type: image/png");
imagepng($image);
imagedestroy ($image);
?>