奥运了,我想弄一个PHP生成奖牌数图片的文件,比如中国得了10块金牌,我在这个PHP文件中设定10,PHP就会生成一张显示10的图片,当中国得到12金牌的时候,我在这个PHP文件中修改设定为12,PHP生成的图片中的数字又变成了12,我想用这个这个文件生成图片做论坛签名,请问这文件用php怎么写?

解决方案 »

  1.   

    header("Content-Type: image/png");
    $data=12;
    $im = @imagecreate(100, 20)
        or die("Cannot Initialize new GD image stream");
    $background_color = imagecolorallocate($im, 0, 0, 0);
    $text_color = imagecolorallocate($im, 233, 14, 91);
    imagestring($im, 1, 5, 5,  $data, $text_color);
    imagepng($im);
    imagedestroy($im);
      

  2.   

    gd画图,简单的直接imagestring,好看点的imagettf系列。
      

  3.   

    网上搜 php生成验证码 一堆堆的
      

  4.   

    $fn = 'http://pic.enorth.com.cn/0/09/23/95/9239587_936940.jpg';
    $s = file_get_contents($fn);
    $ims = imagecreatefromstring($s);
    $w = imagesx($ims)/2;
    $h = imagesy($ims);
    $im = imagecreatetruecolor($w, $h);
    imagecopy($im, $ims, 0, 0, $w, 0, $w, $h);$num = 88;
    $color = imagecolorallocate($im, 255, 0, 0);
    $font = 'c:/windows/fonts/arial.ttf';
    $size = 100;
    $org = imagettfbbox( $size, 0, $font, $num );
    $x = ($w - ($org[2]-$org[0]))/2 + $org[0];
    $y = $h - ($org[1]-$org[7])/2;
    imagettftext($im, $size, 0, $x, $y, $color, $font, $num);imagepng($im);
    细节自己调调吧
      

  5.   

    给你个前卫的方法啊?俺不用PHP~哈哈哈~
    <!doctype html>
    <meta charset=utf-8>
    <html>  
     <head>  
      <title>write demo</title>  
      </head>  
     <body>  
    <canvas id="info" width="300" height="150" style="border:1px solid black"></canvas>
    <script>  
     var canvas = document.getElementsByTagName('canvas')[0];  
     var info = document.getElementById('info');
     var context = canvas.getContext('2d');  
    context.fillStyle    = '#00f';
    context.font         = 'italic 30px sans-serif';
    context.textBaseline = 'top';
    context.fillText  ('Hello world!', 0, 0);
    context.font         = 'bold 30px sans-serif';
    context.fillText  ('1 2 3 4 5 6 7 8 9 ', 0, 80);
    context.font         = 'bold 30px sans-serif';
    context.strokeText('Hello 二胖!', 0, 50); 
    </script>  
    </body>  
    </html>  IE6什么的都旁观,注意文件编码哦