<?php
header (“Content-type: image/png”);

//$str = $_REQUEST[\’str\’] ? $_REQUEST[\’str\’]:”暂\n无\n输\n入”;
$str = “1\n2\n3\n”;
$im = imagecreate(100,120);
$white = imagecolorallocate($im,0xFF,0xFF,0xFF);
imagecolortransparent($im,$white);  //imagecolortransparent() 设置具体某种颜色为透明色,若注释
$black = imagecolorallocate($im,0x00,0x00,0x00);

imagettftext($im,15,0,50,40,$black,”simkai.ttf”,$str); //字体设置部分linux和windows的路径可能不同
header(“Content-type:image/png”);
imagepng($im);//文字生成的图片

//两张图片合成方法
$A = “1.png”;
$B = “test.png”;

$x = 20;
$y = 20;
$rh = 50;

$im1 = imagecreatefromstring(file_get_contents($A));
$im2 = imagecreatefromstring(file_get_contents($B));

imagecopymerge($im1, $im2, $x, $y, 0, 0, imagesx($im2), imagesy($im2), $rh);

imageGif($im1);
?>

版权声明:本文为fengms原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/fengms/p/5417175.html