右下角文字水印

<?php 
function watermark($imgname,$string){
	list($sw,$sh,$imgType) = getimagesize($imgname);
	$types = array('1' => 'gif', '2' => 'jpeg', '3' => 'png' );
	$createImg = 'imagecreatefrom'.$types[$imgType];
	$imgsrc = $createImg($imgname);

	$gray = imagecolorallocate($imgsrc, 200, 200, 200);
	$green = imagecolorallocate($imgsrc, 0, 200, 0);

	$x = $sw - imagefontwidth(5)*strlen($string) - 10;
	$y = $sh - imagefontheight(5) - 10;

	imagestring($imgsrc, 5, $x, $y, $string, $gray);
	imagestring($imgsrc, 5, $x+1, $y+1, $string, $green);

	$save = 'image'.$types[$imgType];
	$save($imgsrc, 'new_' . $imgname);

	imagedestroy($imgsrc);
}

watermark('me.jpg','qdgithub.com');

 ?>

右下角图片水印

<?php
function watermark($imgname,$watername){
	list($sw,$sh,$imgType) = getimagesize($imgname); // 原图
	list($ww,$wh,$wType) = getimagesize($watername); // 水印图
	$types = array('1' => 'gif', '2' => 'jpeg', '3' => 'png' );

	$createImg = 'imagecreatefrom'.$types[$imgType];
	$createwImg = 'imagecreatefrom'.$types[$wType];
	$dst_im = $createImg($imgname);
	$src_im = $createwImg($watername);

	$x = $sw - $ww - 10;
	$y = $sh - $wh - 10;
	imagecopy($dst_im, $src_im, $x, $y, 0, 0, $ww, $wh);


	$save = 'image'.$types[$imgType];
	$save($dst_im, 'new_' . $imgname);
	imagedestroy($dst_im);
	imagedestroy($src_im);
}

watermark('me.jpg','logo.png');

 ?>