<?php
header("Content-Type: image/jpeg");
//(because the script outputs picture)
$transparency = 40; //watermark's transparency (0-100)
//source photo
$source_photo = stripslashes($_GET['photo']);
$photo = imagecreatefromjpeg($source_photo);
//watermark
$watermark = imagecreatefrompng('watermark.png');
$watermark_width = imagesx($watermark);
$watermark_height = imagesy($watermark);
//location of the watermark on the source image
$size = getimagesize($source_photo);
$dest_x = ($size[0] - $watermark_width) / 2;
$dest_y = ($size[1] - $watermark_height) / 2;
//make the image (merge source image with watermark)
imagecopymerge($photo, $watermark, $dest_x, $dest_y, 0, 0, $watermark_width, $watermark_height, $transparency);
//output the image
imagejpeg($photo);
//free memory
imagedestroy($photo);
imagedestroy($watermark);
?>