<?php
$f = "http://ep.yimg.com/ca/I/".$_GET["i"];
if($f!="") {
	$img = imagecreatefromjpeg($f)
		or die("failed on loading image from ".$f);
	if($img) {	
		$watermark = imagecreatefrompng("watermark.png")
			or die("failed on loading watermark");
		$marge_right = 10;
		$marge_bottom = 10;
		$sx = imagesx($watermark);
		$sy = imagesy($watermark);
		$ix = imagesx($img);
		$iy = imagesy($img);

		$wx = ($ix - $sx) / 2;
		$wy = ($iy - $sy) / 2;

		imagecopymerge($img, $watermark, $wx, $wy, 0, 0, $sx, $sy, 50)
			or die("failed on adding watermark");

		//$black = imagecolorallocate($img, 0x00, 0x00, 0x00);
		//$ttf = "arial.ttf";
		//imagefttext($img, 16, 0, 10, 30, $black, $ttf, "Note - the watermark (\"overstockArt.com\") will not appear on the painting itself...");

		header("Content-Type: image/jpeg");
		imagejpeg($img,null,100);

		imagedestroy($img);
		if($watermark) {
			imagedestroy($watermark);
		}
	}
}
else {
	echo "no file given";
}
?>