---
title: "imageString 画图文"
author: "yd514"
date: "2013-05-24T14:28:04Z"
tags: []
categories: ["Web前端"]
slug: "imagestring"
draft: false
lastmod: "2013-05-24T14:28:04Z"
id: 1874652
url: "https://yd514.iteye.com/blog/1874652"
---

&lt;?php  
$width  = 955;  //38份25px/份  
$height = 71;   //三行20px/行  
//创建背景图  
$image = ImageCreateTrueColor($width, $height);  
imageantialias($image,true);  
//浅黄色背景  
$Lightyellow = imagecolorallocate($image,251,255,221);  
imagefill($image,0,0,$Lightyellow);  
//灰色边框  
$gray = imagecolorallocate($image,235,235,235);  
imageFilledRectangle($image, 10, 10, $width-10, $height-10, $gray);  
imageFilledRectangle($image, 11, 11, $width-11, $height-11, $Lightyellow);  
imageline($image, 11, $height/2, $width-11, $height/2, $gray);

// 载入图像  
$imagen1 = imagecreatefrompng("a.png");  
$imagen2 = imagecreatefrompng("b.png");  
// 画线  
$lineColor = imagecolorallocate($image,129,129,129);  
imageline ($image, 11, 11, 11+25, 11+21, $lineColor);  
imageline ($image, 11+25, 11+23, 11+50,11+23, $lineColor);  
imageline ($image, 11+50,11+23, 11+75, 11, $lineColor);  
// 复制图像  
imagecopy($image,$imagen2,6,6,0,0,12,12);  
imagecopy($image,$imagen1,6+25,6+21,0,0,12,12);  
imagecopy($image,$imagen1,6+50,6+21,0,0,12,12);  
imagecopy($image,$imagen2,6+75,6,0,0,12,12);  
//在图像上写文字  
$red = imagecolorallocate($image,255,0,24);  
imageString ($image, 12, 140, 20, "I'm PHP draw word", $red);  
//设定文件头  
header('Content-type: image/png');  
//输出图像  
imagepng($image);  
//释放资源  
imagedestroy($image);  
imagedestroy($imagen1);  
imagedestroy($imagen2);  
?&gt;