Не могу наложить вотемарк, вроде всё верно. Думаю, что проблема в перезаписи изображения.
$image_path = "watermark.png";
$oldimage_name = "img.png";
function watermark_image($oldimage_name){
// получаем имя изображения, используемого в качестве водяного знака
global $image_path;
$type = array_pop(explode(".",$oldimage_name));
list($owidth,$oheight) = getimagesize($oldimage_name);
if($type=='png') {
$im = imagecreatetruecolor($owidth, $oheight);
$img_src = imagecreatefrompng($oldimage_name);
imagecopyresampled($im, $img_src, 0, 0, 0, 0, $owidth, $oheight, $owidth, $oheight);
}
if($type=='gif') {
$im = imagecreatetruecolor($owidth, $oheight);
$img_src = imagecreatefromgif($oldimage_name);
imagecopyresampled($im, $img_src, 0, 0, 0, 0, $owidth, $oheight, $owidth, $oheight);}
if($type=='jpeg') {$im = imagecreatefromjpeg($oldimage_name);}
if($type=='jpg') {$im = imagecreatefromjpeg($oldimage_name);}
if($type=='PNG') {
$im = imagecreatetruecolor($owidth, $oheight);
$img_src = imagecreatefrompng($oldimage_name);
imagecopyresampled($im, $img_src, 0, 0, 0, 0, $owidth, $oheight, $owidth, $oheight);
}
if($type=='GIF') {
$im = imagecreatetruecolor($owidth, $oheight);
$img_src = imagecreatefromgif($oldimage_name);
imagecopyresampled($im, $img_src, 0, 0, 0, 0, $owidth, $oheight, $owidth, $oheight);}
if($type=='JPEG') {$im = imagecreatefromjpeg($oldimage_name);}
if($type=='JPG') {$im = imagecreatefromjpeg($oldimage_name);}
$watermark = imagecreatefrompng($image_path);
list($w_width, $w_height) = getimagesize($image_path);
$pos_x = $owidth - $w_width-5;
$pos_y = $oheight - $w_height-5;
imagecopy($im, $watermark, $pos_x, $pos_y, 0, 0, $w_width, $w_height);
if($type=='png') {unlink($oldimage_name); imagepng($im, $oldimage_name, 9);}
if($type=='gif') {unlink($oldimage_name); imagegif($im, $oldimage_name, 100);}
if($type=='jpeg') {unlink($oldimage_name); imagejpeg($im, $oldimage_name, 100);}
if($type=='jpg') {unlink($oldimage_name); imagejpeg($im, $oldimage_name, 100);}
if($type=='PNG') {unlink($oldimage_name); imagepng($im, $oldimage_name, 9);}
if($type=='GIF') {unlink($oldimage_name); imagegif($im, $oldimage_name, 100);}
if($type=='JPEG') {unlink($oldimage_name); imagejpeg($im, $oldimage_name, 100);}
if($type=='JPG') {unlink($oldimage_name); imagejpeg($im, $oldimage_name, 100);}
imagedestroy($im);
return true;
}