zoukankan      html  css  js  c++  java
  • PHP imagechar() 图形验证码 字体太小问题

    bool imagechar ( resource $image , int $font , int $x , int $y , string $c , int$color )

    imagechar() 将字符串 c 的第一个字符画在 image 指定的图像中,其左上角位于 xy(图像左上角为 0, 0),颜色为 color。如果 font 是 1,2,3,4 或 5,则使用内置的字体(更大的数字对应于更大的字体)。

     

    Example #1 imagechar() 例子

    <?php
        @header("Content-type: image/png");
        $im = imagecreatetruecolor(400, 30);
    
        $white = imagecolorallocate($im, 255, 255, 255);
        $grey = imagecolorallocate($im, 128, 128, 128);
        $black = imagecolorallocate($im, 0, 0, 0);
        imagefilledrectangle($im, 0, 0, 399, 29, $white);
    
        $text = 'Testing...';
        $font = 'arialnarrow.ttf';
        $font_size=12;
        $wing=0;
        $left=5;
        $high=21;
    
        imagettftext($im, $font_size, $wing, $left,$high, $grey, $font, $text);
      
        imagepng($im);
        imagedestroy($im);
    ?>

       解决方案:更换字体,例如  arialnarrow.ttf

     问题解决! 

  • 相关阅读:
    栈的实现方式
    复合和继承
    循环链表和双向链表
    抽象类和接口
    private构造器和单例模式
    内部类
    关于初始化和清理
    多态的理解
    幾個小知識
    Youth
  • 原文地址:https://www.cnblogs.com/DaBing0806/p/5416542.html
Copyright © 2011-2022 走看看