php画图操作 写入文字 写入图片

画布中写入字符串

	$bg_img = imagecreatefromjpeg('pic001.jpg');  //读取图片
    $title = '写入内容';
    $color = imagecolorallocate($bg_img, 100, 100, 100); //设置字体颜色
    $textfont = 18;  //写入字体大小(像素)
    $x = 180;  //插入x坐标
    $y = 673;  //插入y坐标
    $font_d = 'songti'; //字体文件
    imagettftext($bg_img, $textfont, 0, $x, $y, $color, $font_d, $title);

画布中写入图片

$bg_img = imagecreatefromjpeg('pic001.jpg');  //读取图片
$zw_img = imagecreatefrompng('pics.png');
$thumb_width = imagesx($zw_img); //图片宽度
$thumb_height = imagesy($zw_img);  //图片高度
//xy轴为 图片插入的起始点
$x = 120; 
$y = 1035;
$inw = 60;   //画出的结果宽度
$inh = 60;   //画出的结果高度
imagecopyresampled($bg_img, $zw_img, $x, $y, 0, 0, $inw,$inh, $thumb_width, $thumb_height);
    

猜你喜欢

转载自blog.csdn.net/jackbon8/article/details/106405366