• PHP图像处理


    1.创建画布:

      $img=imagescreatetruecolor(200,200);

      创建颜色并填充

      $red=imagecolorallocate($img,255,0,0);  //创建颜色

      $imagefill($img,0,10,$red);  //填充颜色

    2.画图形

      矩形:

        

        imagedrectangle($img,90,10,190,80,$green); 不填充的矩形
        imagefilledrectangle($img,90,10,190,80,$green); 填充的矩形

      线段:

        imageline($img,0,0,200,200,$blue);

      点:

        imagesetpixel ($img,50,50,$red);

      圆:

        imageellipse ($img,100,100,100,100,$green);

          image

          由图象创建函数(例如imagecreatetruecolor())返回的图象资源。

          cx

          中间的 X 坐标。

          cy

          中间的 Y 坐标。

          width

          椭圆的宽度。

          height

          椭圆的高度。

          color

          椭圆的颜色。颜色标识符由 imagecolorallocate() 创建。

      圆形:

        imagefilledarc($img,50,50,-160,40,$green);

        

      圆弧:

        imagefilledarc($img,50,50,100,50-160,40,$green,IMG_ARC_RIE);

          bool imagefilledarc ( resource image, int cx, int cy, int w, int h, int s, int e, int color, int style )
           imagefilledarc() 在 image 所代表的图像中以 cxcy(图像左上角为 0, 0)画一椭圆弧。如果成功则返回 TRUE,失败则返回 FALSEw 和 h 分别指定了椭圆的宽和高,s 和 e 参数以角度指定了起始和结束点。style 可以是下列值按位或(OR)后的值:

      写字符到图像:

        水平画:imagechar($img,5,100,100,"ABCDEFG",$red);

        垂直画:imagecharup($img,5,100,100,"ABCDEFGHIJK",$red);

    3.输出资源

        header("Content-type:image/gif");

        imagegif($img);

    4.释放资源

        imagedestry($img);

  • 相关阅读:
    python requests 上传excel数据流
    No module named 'requests_toolbelt'
    code
    pytest 打印调试信息
    python3 获取日期时间
    Java单元测试之JUnit篇
    The import junit cannot be resolved解决问题
    什么是索引
    python3 ini文件读写
    js 测试题
  • 原文地址:https://www.cnblogs.com/subtract/p/3870767.html
Copyright © 2020-2023  润新知