$size = 30;
$font = "fonts/GB2312.ttf";
$text = "杨幂";
//创建空白图片
$img = imagecreate(140, 50);
//图片配色
imagecolorallocate($img, 0xff, 0xff, 0xff);
//字体配色
$black = imagecolorallocate($img, 0, 0, 0);
//文字转变为图片
imagettftext($img, $size, 0, 10, 40, $black, $font, $text);
header('Content-Type:image/png');
// imagepng($img);
$file = imagepng($img,"2.png");
imagedestroy($img);
// echo $file;
//
$bigImgPath = "20171226152410.jpeg";
$qCodePath = "2.png";
$bigImg = imagecreatefromstring(file_get_contents($bigImgPath));
$qCodeImg = imagecreatefromstring(file_get_contents($qCodePath));
list($qCodeWidth, $qCodeHight, $qCodeType) = getimagesize($qCodePath);
imagecopymerge($bigImg, $qCodeImg, 100, 100, 0, 0, $qCodeWidth, $qCodeHight, 100);
list($bigWidth, $bigHight, $bigType) = getimagesize($bigImgPath);
imagepng($bigImg,'3.png');
|