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);
  • 相关阅读:
    centos 7安装配置vsftpd
    lvs和haproxy机器必须注意的三个参数
    用python 脚本实现zabbix对java端口报警
    git的下载地址
    看的一篇很好的博客
    学习内容
    数组一些用法
    dom
    dom1
    for的基础
  • 原文地址:https://www.cnblogs.com/zsongs/p/6099864.html
Copyright © 2011-2022 走看看