html.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /**
  3. * User: lang
  4. * Date: 2023/8/9
  5. * Time: 17:12
  6. */
  7. use Kkokk\Poster\Facades\Html;
  8. use Kkokk\Poster\Facades\Poster;
  9. require '../../vendor/autoload.php';
  10. $html = <<<HTML
  11. <!doctype html>
  12. <html lang="en">
  13. <head>
  14. <meta charset="UTF-8">
  15. <meta name="viewport"
  16. content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
  17. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  18. <title>你好</title>
  19. <style>
  20. html, body{
  21. margin: 0;
  22. padding: 0;
  23. }
  24. .app {
  25. width: 338px;
  26. height: 426px;
  27. background: -webkit-linear-gradient(top left,red, orange, yellow, green, blue, purple);
  28. border-radius: 40px;
  29. }
  30. h1{
  31. margin: 0;
  32. text-align: center;
  33. }
  34. </style>
  35. </head>
  36. <body>
  37. <div class="app">
  38. <h1>你好,世界</h1>
  39. </div>
  40. </body>
  41. </html>
  42. HTML;
  43. $img = Html::channel('wk')->load($html)->transparent()->size(338, 426)->render();
  44. $result = Poster::extension('gd')
  45. ->config([
  46. 'path' => __DIR__ . '/../poster/test1.png',
  47. ])
  48. ->buildIm(638, 826, [41, 43, 48, 127], false)
  49. ->buildImage([
  50. // 'src' => __DIR__ . '/../poster/1689560381.png',
  51. 'src' => $img->getImageBlob(),
  52. 'angle' => 0
  53. ], 'center', 'center')
  54. ->buildImage([
  55. 'src' => 'https://portrait.gitee.com/uploads/avatars/user/721/2164500_langlanglang_1601019617.png',
  56. 'angle' => 80
  57. ], 253, 326, 0, 0, 131, 131, false, 'circle')
  58. ->buildText('苏轼', 'center', 477, 16, [255, 255, 255, 1])
  59. ->buildText('明月几时有,把酒问青天。不知天上宫阙,今夕是何年。', 'center', 515, 14, [255, 255, 255, 1])
  60. ->stream();