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)

  • 相关阅读:
    Linux vi/vim
    Linux 磁盘管理
    Linux 用户和用户组管理
    Linux 文件与目录管理
    Linux 文件基本属性
    Linux 远程登录
    Linux 忘记密码解决方法
    Linux 系统目录结构
    Linux 系统启动过程
    linux -- su和sudo命令的区别
  • 原文地址:https://www.cnblogs.com/wjlbk/p/12633457.html
Copyright © 2011-2022 走看看