This article brings the content is about how PHP to achieve image synthesis and generate watermark (complete code), there is a certain reference value, the need for friends can refer to, I hope to help you.
<?php$dst_path = './upload/goods/2018/06-04/2bd2518a2e4e6d8bdab9f01434b9f754.png '; $src _path = './public/upload/ Weixin/20180620/a643cf1ee7dd5bda12270647ca543f60.png '; $hz = substr (STRRCHR ($dst _path, '. '), 1); $image = Date ("Ymdhis "). Rand (100000,999999).". ". $hz;//Create an instance of the picture $dst = Imagecreatefromstring (file_get_contents ($DST _path)); $src = Imagecreatefromstring (file_get_ Contents ($src _path));//obtain a watermark image of the wide-height $src_w =139; $src _h=58;list ($src _w, $src _h) = getimagesize ($src _path);// If the watermark picture itself is transparent, use the Imagecopy method Imagecopy ($DST, $SRC, 85,85, 0, 0, $src _w, $src _h);//Output Picture list ($src _w, $src _h, $dst _type) = GetImageSize ($dst _path), switch ($dst _type) {case 1://gif header (' content-type:image/gif '); Imagegif ($DST, ".". $image); Break Case 2://jpg Header (' content-type:image/jpeg '); Imagejpeg ($DST, ".". $image); Break Case 3://png Header (' content-type:image/png '); Imagepng ($DST, ".". $image); Break Default:break;} ImAgedestroy ($DST); Imagedestroy ($SRC); return $image;