This article mainly introduces the PHP use of the GD library for the page to add watermark to the specific implementation, the need for friends can refer to the following
Code as follows: <?php header ("Content-type:image/png"); $conn = mysql_connect ("localhost", "root", ""); Connection database $colname _rs_article = $_get[' id ']; Get Parameters id mysql_select_db ("CMS", $conn); Execute sql $query _rs_article = sprintf ("SELECT * from articles WHERE article_id =%s", $colname _rs_article); $rs _ Article = mysql_query ($query _rs_article, $conn) or Die (Mysql_error ()); $row _rs_article = Mysql_fetch_assoc ($rs _ article); $totalRows _rs_article = mysql_num_rows ($rs _article); $image = Imagecreatetruecolor (700, 1000); Create canvas $BG = imagecolorallocate ($image, 255, 255, 255); Set the background to white Imagefill ($image, 0, 0, $BG); $text _color = imagecolorallocate ($image, 0, 0, 0); Set text color to black imagestring ($image, 5, 0, 0, $row _rs_article[' title '), $text _color); Output article title imagestring ($image, 3, 0, $row _rs_article[' author '), $text _color); Output article author imagestring ($image, 4, 0, $row _rs_article[' content '), $text _color); Output article content $logo = imagecreatefrompng (' logo.png '); Get watermark picture $logoW = Imagesx ($logo); $logoH = Imagesy ($logo); imagecopy ($image, $logo, 0, 0, 0, 0, $logoW, $logoH); Combine text picture with watermark picture imagejpeg ($image); Output to browser Imagedestroy ($logo); Imagedestroy ($image); ?>