$stamp = imagecreatefrompng('watermark.png');
$im = imagecreatefromstring(file_get_contents($_GET['img']));
$pc = imagesx($im) / 300;
$s_w = imagesx($stamp) * $pc;
$s_h = imagesy($stamp) * $pc;
$stamp_p = imagecreatetruecolor($s_w, $s_h);
imagealphablending($stamp_p, false);
imagesavealpha($stamp_p, true);
imagecopyresampled($stamp_p, $stamp, 0, 0, 0, 0, $s_w, $s_h, imagesx($stamp), imagesy($stamp));
$marge_right = 10;
$marge_bottom = 10;
$sx = imagesx($stamp_p);
$sy = imagesy($stamp_p);
imagecopy($im, $stamp_p, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, $sx, $sy);
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);