shish 2 лет назад
Родитель
Сommit
3cf67e4e1f
1 измененных файлов с 24 добавлено и 17 удалено
  1. 24 17
      app-ghs/controllers/TestController.php

+ 24 - 17
app-ghs/controllers/TestController.php

@@ -40,23 +40,30 @@ class TestController extends BaseController
     public function actionIp()
     public function actionIp()
     {
     {
         error_reporting(-1);
         error_reporting(-1);
-//        $ip = $_SERVER['SERVER_ADDR'] ?? '';
-//        echo $ip;
-
-//        $converter = new PDFConverter([
-//            "out" => "test.pdf"
-//        ]);
-//        $converter->add(new PDFObject(
-//            file_get_contents("http://www.google.co.uk")));
-//        $converter->convert();
-
-        $c = new Converter(null, [
-            "fmt" => "png",
-            "in" => "https://www.baidu.com",
-            "out" => "test.png"
-        ]);
-        var_dump($c);
-        //$c->convert();
+
+        // 设置画布宽度和高度
+        $width = 400;
+        $height = 400;
+
+// 创建一个空白的画布
+        $image = imagecreatetruecolor($width, $height);
+
+// 从HTML文件中读取内容
+        $html = file_get_contents('<div style="color:red;">aaa</div>');
+
+// 在画布上输出HTML内容
+        imagestring($image, 5, 0, 0, $html, 0x000000);
+
+// 将画布保存为PNG格式图像
+        imagepng($image, 'output.png');
+
+// 显示图像
+        header('Content-Type: image/png');
+        imagepng($image);
+
+// 释放画布资源
+        imagedestroy($image);
+
 
 
     }
     }