php生成推广二维码海报、合成图片
1、海报背景图。背景图一般存服务器,程序本地读取;
2、推广二维码。可以是二维码图片链接,也可以是字符串图像流。如果自己生成二维码,详见phpqrcode官网,地址:https://sourceforge.net/projects/phpqrcode。
3、开启PHP的GD扩展
index.php
<?phprequire_once "Imgcode.php";$codedata = array("portrait" => array("thumb" => 'test.jpg', "left" => 40, "top" => 40, "width" => 100, "height" => 100), // 店铺logo"shopname" => array("text" => '店铺名称', "left" => 160, "top" => 80, "size" => 28, "width" => 360, "height" => 50, "color" => "#333"), // 店铺名称"thumb" => array("thumb" => 'code.png', "left" => 40, "top" => 160, "width" => 560, "height" => 560), // 店铺二维码"desc" => array("text" => "长按二维码扫码进入", "left" => 210, "top" => 980, "size" => 18, "color" => "#666"));$parameter = array("goodsid" => 'goodsid', "qrcode" => 'code.png',/* 二维码地址 */ "codedata" => $codedata, "mid" => 0, "codeshare" => 1);$img = createcode($parameter);echo '<img src="'.$img.'" height="100%">';?>
Imgcode.php
<?phpfunction createcode