PHP怎么生成数字图片 奥运了,我想弄一个PHP生成奖牌数图片的文件,比如中国得了10块金牌,我在这个PHP文件中设定10,PHP就会生成一张显示10的图片,当中国得到12金牌的时候,我在这个PHP文件中修改设定为12,PHP生成的图片中的数字又变成了12,我想用这个这个文件生成图片做论坛签名,请问这文件用php怎么写? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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); gd画图,简单的直接imagestring,好看点的imagettf系列。 网上搜 php生成验证码 一堆堆的 $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);细节自己调调吧 给你个前卫的方法啊?俺不用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什么的都旁观,注意文件编码哦 请问linux下xampp集成环境中怎么为php添加curl扩展? php有关问题 验证码问题 js和session读取不同步 各个站点用户共享 PHP的session 有没有类似Java session中的监听器功能 两个不同表之间的字段怎么关联插入 求生成复杂验证码程序 求一段php正则替换规则 php使用SOAP问题 (如果能够解决另有百分相送) 在用editplus编php时,php不能高亮显示,怎样在editplus中设置? 如何修改MYSQL默认的排序方式 apahce module php 与 apahce+fastcgi 那种方式好点
$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);
$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);
细节自己调调吧
<!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什么的都旁观,注意文件编码哦