zoukankan      html  css  js  c++  java
  • PHP

    ```php
    <?php
    header("content-type:image/jpeg");
    $width = 120;
    $height = 40;
    $img = imagecreatetruecolor($width,$height);

    $color_bg = imagecolorallocate($img,rand(200,255),rand(200,255),rand(200,255));
    $color_str = imagecolorallocate($img,rand(10,100),rand(10,100),rand(10,100));
    $element = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'];
    $str = "";
    for($i=0;$i<5;$i++) {
        $str.=$element[rand(0,count($element)-1)];
    }

    imagefill($img,0,0,$color_bg);

    //imagesetpixel — 画一个单一像素
    //imagesetpixel( resource $image, int $x, int $y, int $color) : bool
    //imagesetpixel() 在 image 图像中用 color 颜色在 x,y 坐标(图像左上角为 0,0)上画一个点。
    //循环输出,可以重复输出点
        for($i=0;$i<100;$i++) {
            imagesetpixel($img,rand(0,$width-1),rand(0,$height-1),$color_str);
        }

        //循环输出多条线
        for($i=0;$i<3;$i++) {
            imageline($img,rand(0,$width/2),rand(0,$height),rand($width/2,$width),rand(0,$height),$color_str);
        }

        //imagettftext — 用 TrueType 字体向图像写入文本
        imagettftext($img,25,rand(-5,5),rand(5,15),rand(30,35),$color_str,'fonts/ywsfxs.ttf',$str);

    imagejpeg($img);
    //最后要释放内存
    imagedestroy($img);

    //金龙制作
    ```

    效果图;
    ![效果图片](https://img-blog.csdnimg.cn/20191110222350430.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MjE5MDg5Mw==,size_16,color_FFFFFF,t_70)

  • 相关阅读:
    EasyUI——常见用法总结
    递归算法(转)
    1215整理
    jQuery Ajax 实例 全解析(转)
    EL表达式 (详解)
    JSTL 核心标签库 使用(转)
    JSTL标签用法 详解(转)
    JDBC连接Oracle数据库时出现的ORA-12505错误及解决办法
    java中的基本jdbc中mvc基本示例
    Hibernate的QBC检索方式
  • 原文地址:https://www.cnblogs.com/wjlbk/p/12633456.html
Copyright © 2011-2022 走看看