doushi2902 2013-01-23 06:23
浏览 42

PHP font_size验证码

I tried to change the $font_size but it seems it is not working. It stays the same no matter what. Even if I altered the $font_size up to 130. It stays the same:

<?php
    header('Content-type: image/png');

    $rand_num = rand(1000, 9999);

    $font_size = 130;

    $image_width = 110;
    $image_height = 20;

    $image = imagecreate($image_width, $image_height);
    imagecolorallocate($image, 255, 255, 255);
    $black_color = imagecolorallocate($image, 0, 0, 0);

    imagestring($image, $font_size, 0, 0, $rand_num, $black_color);

    for($x=0; $x <= 30; $x++){
        $x1 = rand(1, 100); 
        $y1 = rand(1, 100);
        $x2 = rand(1, 100);
        $y2 = rand(1, 100);

        imageline($image, $x1, $y1, $x2, $y2, $black_color);
    }

    imagepng($image);
?>
  • 写回答

3条回答 默认 最新

  • douwu5428 2013-01-23 06:25
    关注

    According to PHP Manual, The font parameter

    Can be 1, 2, 3, 4, 5 for built-in fonts in latin2 encoding (where higher numbers corresponding to larger fonts) or any of your own font identifiers registered with imageloadfont().

    So you have to try 1 2 3 4 5 and not 130.

    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?