....这么久都不结贴?
<?php
//filename : gd003.php
//macleo 2008.9.19.
header("Content-Type: image/png");
//defined ttf location and text will display
$font_path = "font/";
$font_name = $font_path."fzhc_GBK.ttf";
$text = "点燃激情,传递梦想!!";
$picname = "test";$im = imagecreatetruecolor(800, 100);// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 100, 100, 100);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 800, 100, $white);
//array imagettftext ( resource $image, float $size, float $angle, int $x, int $y, int $color, string $fontfile, string $text )
imageline ( $im, 799, 0, 0, 0, $black );//top
imageline ( $im, 799, 99, 0, 99, $black );//bottom
imageline ( $im, 0, 99, 0, 0, $black );//left
imageline ( $im, 799, 99, 799, 0, $black );//right        imagettftext($im, 50, 0, 52, 62, $grey, $font_name, $text);        // Add the text
        imagettftext($im, 50, 0, 50, 60, $black, $font_name, $text);        //display        //header('Content-disposition: inline; filename='.$picname.'.png');
        imagepng($im);
        ImageDestroy($im);
?>
见效果截图:http://hiphotos.baidu.com/macleo/pic/item/5eb5e5036963666e3812bb49.jpg

解决方案 »

  1.   

    <?php
    // set up image 
      $height = 200;
      $width = 200;
      $im = ImageCreateTrueColor($width, $height);
      $white = ImageColorAllocate ($im, 255, 255, 255);
      $blue = ImageColorAllocate ($im, 0, 0, 64);
      $wenben = "请填写文本框内容,否则程序将无法生成图片文字";
    //判断文本框是否填写
     //if ( (empty($wenben)) )
      //  {
     //    echo '请填写文本框内容,否则程序将无法生成图片文字';
     //    exit;
      //  }
    /*  if ( $wenben == '' )
      {
      echo '请填写文本内容';
      exit; 
      
      }*/
    // draw on image  
      
      ImageFill($im, 0, 0, $blue);
      ImageLine($im, 0, 0, $width, $height, $white);
      //putenv('GDFONTPATH=C:\WINDOWS\Fonts');
      //$font="simfang.tiff";
      $font="simkai.ttf";//imagettftext($im, 20,0, 50, 150, $white ,$font,iconv('UTF-8','UTF-8',$wenben));
    imagettftext($im, 20,0, 50, 150, $white ,$font,$wenben);// output image
      Header ('Content-type: image/png');
      ImagePng ($im);
      
    // clean up 
      ImageDestroy($im);
      
     
     
     
    ?>