/* 步骤: 1.分别创建大小图画布并获取它们的宽高 2.添加文字水印 3.执行图片水印处理 4.输出 5.销毁画布 */ //1.分别创建大小图画布并获取它们的宽高 $big = imagecreatefromjpeg(‘./bg.jpg‘); $bx = imagesx($big); $by = imagesy($big); $small = imagecreatefrompng(‘./tu.png‘); $sx = imagesx($small); $sy = imagesy($small); //2.添加水印文字 $blue = imagecolorallocate($big,0,0,255); imagettftext($big,16,0,100,100,$blue,‘./msyh.ttf‘,‘骄傲的少年‘); //3.执行图片水印处理 imagecopymerge($big,$small,$bx-$sx,0,0,0,$sx,$sy,37); //4.输出到浏览器 header(‘content-type: image/jpeg‘); imagejpeg($big); //5.销毁画布 imagedestroy($big); imagedestroy($small);
时间: 2024-10-13 00:28:45