zoukankan      html  css  js  c++  java
  • php 画图片3

    <?php
        
        // 中文验证码
        // 1. 创建画布
        $im = imagecreatetruecolor(200, 200);
    
        // 2. 创建背景色
        // 2.1得到背景颜色
        $bg_color = imagecolorallocate($im, mt_rand(200, 255), mt_rand(200, 255), mt_rand(200, 255));
    
        // 2.2 填充画布
        imagefill($im, 0, 0, $bg_color);
    
        //3. 获取验证码数据
        $captcha = '北京您好';
    
        //4. 将验证码写入图片
        //4.1得到文字颜色
        $str_color = imagecolorallocate($im,mt_rand(0,100),mt_rand(0,100),mt_rand(0,100));
        
        //4.2将字符串写入图片
        imagettftext($im, 20, mt_rand(-90, 90), 100, 120, $str_color, 'STHUPO.TTF', '北');
        imagettftext($im, 20, mt_rand(-90, 90), 80, 120, $str_color, 'STHUPO.TTF', '京');
        imagettftext($im, 20, mt_rand(-90, 90), 90, 120, $str_color, 'STHUPO.TTF', '您');
        imagettftext($im, 20, mt_rand(-90, 90), 50, 120, $str_color, 'STHUPO.TTF', '好');
    
        // 指定类型
        header('Content-type:image/png');
    
        imagepng($im);
    
        //释放资源
        imagedestroy($im);
  • 相关阅读:
    POJ1045 Bode Plot
    POJ1044 Date bugs
    POJ1043 What's In A Name?
    POJ1042 Gone Fishing
    POJ1041 John's trip
    POJ1040 Transportation
    POJ1039 Pipe
    background-size属性
    一些CSS的备忘
    only-child选择器
  • 原文地址:https://www.cnblogs.com/zsongs/p/6099864.html
Copyright © 2011-2022 走看看