mirror of
https://gitee.com/niucloud-team/niucloud.git
synced 2025-12-13 02:02:47 +00:00
update
This commit is contained in:
parent
6c471906d0
commit
bbc08b404e
Binary file not shown.
|
Before Width: | Height: | Size: 3.1 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 4.0 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 3.4 MiB |
BIN
niucloud/vendor/kkokk/poster/tests/JoJhekR1um.png
vendored
BIN
niucloud/vendor/kkokk/poster/tests/JoJhekR1um.png
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 67 KiB |
BIN
niucloud/vendor/kkokk/poster/tests/Kvt1cV5ygB.png
vendored
BIN
niucloud/vendor/kkokk/poster/tests/Kvt1cV5ygB.png
vendored
Binary file not shown.
|
Before Width: | Height: | Size: 230 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 161 KiB |
@ -1,28 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* User: lang
|
||||
* Date: 2024/3/12
|
||||
* Time: 13:29
|
||||
*/
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
use Kkokk\Poster\Facades\Poster;
|
||||
use Kkokk\Poster\Facades\Html;
|
||||
|
||||
$html = '<p><img src="https://img.alicdn.com/imgextra/i3/2216558867983/O1CN01x1zaRA28qGize0z8Z-2216558867983.png" style="max-width:100%;" contenteditable="false"/><img src="https://img.alicdn.com/imgextra/i3/2216558867983/O1CN018Wkbza28qGgEw9zFc-2216558867983.jpg" style="max-width:100%;" contenteditable="false"/><img src="https://img.alicdn.com/imgextra/i1/2216558867983/O1CN012kv2PV28qGgOLWevq-2216558867983.jpg" style="max-width:100%;" contenteditable="false"/><img src="https://img.alicdn.com/imgextra/i4/2216558867983/O1CN01wkGs3928qGgQ33mpL-2216558867983.jpg" style="max-width:100%;" contenteditable="false"/><img src="https://img.alicdn.com/imgextra/i2/2216558867983/O1CN01aKQZLP28qGgLIwWCo-2216558867983.jpg" style="max-width:100%;" contenteditable="false"/><img src="https://img.alicdn.com/imgextra/i4/2216558867983/O1CN01y16VA428qGgRQVuEa-2216558867983.jpg" style="max-width:100%;" contenteditable="false"/><img src="https://img.alicdn.com/imgextra/i4/2216558867983/O1CN01FPc1GR28qGgTR2N2e-2216558867983.jpg" style="max-width:100%;" contenteditable="false"/><img src="https://img.alicdn.com/imgextra/i2/2216558867983/O1CN01wXODo528qGgNH6UOJ-2216558867983.jpg" style="max-width:100%;" contenteditable="false"/><img src="https://img.alicdn.com/imgextra/i4/2216558867983/O1CN01fKlq4w28qGgKjeXRu-2216558867983.jpg" style="max-width:100%;" contenteditable="false"/><img src="https://img.alicdn.com/imgextra/i3/2216558867983/O1CN01VNiW7U28qGgKjfXre-2216558867983.jpg" style="max-width:100%;" contenteditable="false"/><img src="https://img.alicdn.com/imgextra/i3/2216558867983/O1CN0137I51828qGgNGJssR-2216558867983.jpg" style="max-width:100%;" contenteditable="false"/><img src="https://img.alicdn.com/imgextra/i3/2216558867983/O1CN01LKBile28qGgSe9v8m-2216558867983.jpg" style="max-width:100%;" contenteditable="false"/><img src="https://img.alicdn.com/imgextra/i3/2216558867983/O1CN01tEqT4328qGgjTggJE-2216558867983.jpg" style="max-width:100%;" contenteditable="false"/><img src="https://img.alicdn.com/imgextra/i3/2216558867983/O1CN01wOhqA728qGgnrcyi9-2216558867983.jpg" style="max-width:100%;" contenteditable="false"/></p>';
|
||||
|
||||
$chunkHeight = 1500;
|
||||
|
||||
$poster = Poster::extension('imagick')->buildImDst(Html::load($html)->size(480)->render());
|
||||
$imInfo = $poster->getImInfo();
|
||||
$tmpIm = $poster->tmp();
|
||||
$width = $imInfo['width'];
|
||||
$height = $imInfo['height'];
|
||||
$count = ceil($height / $chunkHeight);
|
||||
for ($i = 0; $i < $count; $i ++) {
|
||||
$y = $chunkHeight * $i;
|
||||
if($i + 1 == $count) {
|
||||
$chunkHeight = $height - $y;
|
||||
}
|
||||
$crop = Poster::buildImDst($tmpIm)->crop(0, $y,$width, $chunkHeight)->getPoster(__DIR__ . '/crop/' . $i . '.png');
|
||||
}
|
||||
24
niucloud/vendor/kkokk/poster/tests/imagick.php
vendored
24
niucloud/vendor/kkokk/poster/tests/imagick.php
vendored
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: lang
|
||||
* Email: 732853989@qq.com
|
||||
* Date: 2023/3/21
|
||||
* Time: 17:39
|
||||
*/
|
||||
use Kkokk\Poster\Exception\PosterException;
|
||||
use Kkokk\Poster\Facades\Poster;
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
try {
|
||||
|
||||
$res = Poster::extension('imagick')
|
||||
->config(['path'=>'poster/imagick.png','font_family'=> __DIR__ . '/../src/style/simkai.ttf'])
|
||||
->buildIm(638,826,[255,255,255,1],true)
|
||||
->getPoster();
|
||||
|
||||
} catch (PosterException $e) {
|
||||
|
||||
print_r($e->getMessage());
|
||||
|
||||
}
|
||||
301
niucloud/vendor/kkokk/poster/tests/index.php
vendored
301
niucloud/vendor/kkokk/poster/tests/index.php
vendored
@ -1,301 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Kkokk\Tests;
|
||||
|
||||
use Kkokk\Poster\Exception\Exception;
|
||||
use Kkokk\Poster\PosterManager;
|
||||
use Kkokk\Poster\Facades\Poster;
|
||||
use Kkokk\Poster\Facades\Captcha;
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
/**
|
||||
* @Author: lang
|
||||
* @Email: 732853989@qq.com
|
||||
* @Date: 2020-08-14 10:07:58
|
||||
* @Last Modified by: lang
|
||||
* @Last Modified time: 2021-09-09 16:54:47
|
||||
*/
|
||||
|
||||
try {
|
||||
// $result = Poster::extension()->Qr('http://www.baidu.com','poster/1.png', 'L', 4, 1, 1);
|
||||
// var_dump($result);
|
||||
// exit;
|
||||
// var_dump(Poster::extension()->config(['path'=>'poster/avatar1.png','font_family'=> __DIR__ . '/../src/style/simkai.ttf'])
|
||||
// ->buildIm(400,400,[255,255,255, 1],true)
|
||||
// ->buildText('Poster', ['center', 22], 'center', 108, [52, 52, 52, 1], '', '', 20)
|
||||
// ->getPoster()
|
||||
// );
|
||||
// exit;
|
||||
// echo microtime().PHP_EOL;
|
||||
// $json = '[{"x":186,"y":182},{"x":94,"y":157}]';
|
||||
// $secret = '[{"contents":"\u7ea2","point":[157,169,185,215,215,197,187,151,-58]},{"contents":"\u70e7","point":[61,150,95,193,123,172,89,129,-51]}]';
|
||||
// $data = PosterManager::Captcha()->type('click')->check(0, json_decode($json, true), 0, $secret);
|
||||
// var_dump($data);
|
||||
// exit;
|
||||
// $data = PosterManager::Captcha()->get();
|
||||
// $data = Captcha::type()->config(['slider_bg'=>-1])->get();
|
||||
// $data = Captcha::type('input')->config(['contents'=>'红烧'])->get();
|
||||
// // $data = PosterManager::Captcha()->type('input')->config(['src'=>__DIR__.'/../src/style/slider_bg/layer01.jpg'])->get();
|
||||
// $data = PosterManager::Captcha()->type('click')->config(['contents'=>'红烧'])->get();
|
||||
// $data = PosterManager::Captcha()->type('input')->config(['type'=>'number'])->get();
|
||||
// $data = PosterManager::Captcha()->type('input')->config(['type'=>'alpha_num'])->get();
|
||||
// $data = PosterManager::Captcha()->type('input')->config(['type'=>'text'])->get();
|
||||
// $data = PosterManager::Captcha()->type('input')->config(['type'=>'math'])->get();
|
||||
// $data = PosterManager::Captcha()->type('rotate')->get();
|
||||
|
||||
// print_r($data['img']);
|
||||
|
||||
// echo (memory_get_usage() / 1024 / 1024).'M'.PHP_EOL;
|
||||
// echo microtime().PHP_EOL;
|
||||
// echo (memory_get_peak_usage() / 1024 / 1024).'M'.PHP_EOL;
|
||||
// print_r(getrusage()).PHP_EOL;
|
||||
// exit;
|
||||
|
||||
# 静态调用
|
||||
// 合成图片
|
||||
// $result = PosterManager::Poster('poster/poster_user')
|
||||
// ->buildIm(638,826,[255,255,255,127],false)
|
||||
// ->buildImage('https://test.acyapi.51acy.com/wechat/poster/top_bg.png')
|
||||
// ->buildImage('https://test.acyapi.51acy.com/wechat/poster/half_circle.png',254,321)
|
||||
// ->buildImage('https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2854425629,4097927492&fm=26&gp=0.jpg',253,326,0,0,131,131,false,'circle')
|
||||
// ->buildImage('https://test.acyapi.51acy.com/wechat/poster/fengexian.png',0,655)
|
||||
// ->buildImage('https://test.acyapi.51acy.com/wechat/qrcode/poster_241.jpg',37,692,0,0,122,122)
|
||||
// ->buildText('苏轼','center',477,16,[51, 51, 51, 1])
|
||||
// ->buildText('明月几时有,把酒问青天。不知天上宫阙,今夕是何年。','center',515,14,[153, 153, 153, 1])
|
||||
// ->buildText('长按识别',497,720,15,[153, 153, 153, 1])
|
||||
// ->buildText('查看TA的更多作品',413,757,15,[153, 153, 153, 1])
|
||||
// ->buildQr('http://www.baidu.com','20%','20%',0,0,8,2)
|
||||
// ->getPoster();
|
||||
|
||||
|
||||
# 批量合成
|
||||
$buildImageManyArr = [
|
||||
[
|
||||
'src' => 'https://test.acyapi.51acy.com/wechat/poster/top_bg.png'
|
||||
],
|
||||
[
|
||||
'src' => 'https://test.acyapi.51acy.com/wechat/poster/half_circle.png', 'dst_x' => 254, 'dst_y' => 321
|
||||
],
|
||||
[
|
||||
'src' => 'https://portrait.gitee.com/uploads/avatars/user/721/2164500_langlanglang_1601019617.png', 'dst_x' => 253, 'dst_y' => 326, 'src_x' => 0, 'src_y' => 0, 'src_w' => 131, 'src_h' => 131, 'alpha' => false, 'type' => 'circle'
|
||||
],
|
||||
[
|
||||
'src' => 'https://test.acyapi.51acy.com/wechat/poster/fengexian.png', 'dst_x' => 0, 'dst_y' => 655
|
||||
]
|
||||
];
|
||||
$buildTextManyArr = [
|
||||
[
|
||||
'content' => '苏轼', 'dst_x' => 'center', 'dst_y' => 477, 'font' => 16, 'rgba' => [51, 51, 51, 1], 'max_w' => 0, 'font_family' => '', 'weight' => 1, 'space' => 20
|
||||
],
|
||||
[
|
||||
'content' => '明月几时有,把酒问青天。不知天上宫阙,今夕是何年。', 'dst_x' => 'center', 'dst_y' => 515, 'font' => 16, 'rgba' => [51, 51, 51, 1]
|
||||
],
|
||||
[
|
||||
'content' => '我欲乘风归去,又恐琼楼玉宇,高处不胜寒。', 'dst_x' => 'center', 'dst_y' => 535, 'font' => 16, 'rgba' => [51, 51, 51, 1]
|
||||
],
|
||||
[
|
||||
'content' => '起舞弄清影,何似在人间。转朱阁,低绮户,照无眠。', 'dst_x' => 'center', 'dst_y' => 555, 'font' => 16, 'rgba' => [51, 51, 51, 1]
|
||||
],
|
||||
[
|
||||
'content' => '不应有恨,何事长向别时圆?', 'dst_x' => 'center', 'dst_y' => 575, 'font' => 16, 'rgba' => [51, 51, 51, 1]
|
||||
],
|
||||
[
|
||||
'content' => '人有悲欢离合,月有阴晴圆缺,此事古难全。', 'dst_x' => 'center', 'dst_y' => 595, 'font' => 16, 'rgba' => [51, 51, 51, 120]
|
||||
],
|
||||
[
|
||||
'content' => '但愿人长久,千里共婵娟。', 'dst_x' => 'center', 'dst_y' => 615, 'font' => 16, 'rgba' => [51, 51, 51, 1]
|
||||
],
|
||||
[
|
||||
'content' => '长按识别', 'dst_x' => 'center', 'dst_y' => 720, 'font' => 16, 'rgba' => [51, 51, 51, 1]
|
||||
],
|
||||
[
|
||||
'content' => '查看TA的更多作品', 'dst_x' => 'center', 'dst_y' => 757, 'font' => 16, 'rgba' => [51, 51, 51, 1], 'max_w' => 0, 'font_family' => '', 'weight' => 1, 'space' => 20
|
||||
]
|
||||
];
|
||||
$buildQrManyArr = [
|
||||
[
|
||||
'text' => 'http://www.520yummy.com', 'dst_x' => 37, 'dst_y' => 692, 'src_x' => 0, 'src_y' => 0, 'src_w' => 0, 'src_h' => 0, 'size' => 4, 'margin' => 1
|
||||
],
|
||||
[
|
||||
'text' => 'http://www.520yummy.com', 'dst_x' => 481, 'dst_y' => 692, 'src_x' => 0, 'src_y' => 0, 'src_w' => 0, 'src_h' => 0, 'size' => 4, 'margin' => 1
|
||||
]
|
||||
];
|
||||
|
||||
// $result = PosterManager::Poster('poster/poster_user')
|
||||
// ->buildIm(638,826,[255,255,255,1],true)
|
||||
// ->buildImageMany($buildImageManyArr)
|
||||
// ->buildTextMany($buildTextManyArr)
|
||||
// ->buildQrMany($buildQrManyArr)
|
||||
// ->buildBg(638,826,[0,0,0,50],true)
|
||||
// ->buildText('明月几时有,把酒问青天。不知天上宫阙,今夕是何年。','center',100,32,[255, 255, 255, 1])
|
||||
// ->getPoster();
|
||||
$startAt = microtime(true);
|
||||
echo $startAt . PHP_EOL;
|
||||
// $result = PosterManager::Poster('poster/poster_user')
|
||||
// ->buildIm(638,826,[255,255,255,1],true)
|
||||
// ->buildImageMany($buildImageManyArr)
|
||||
// ->buildTextMany($buildTextManyArr)
|
||||
// ->buildQrMany($buildQrManyArr)
|
||||
// ->buildBg(638,826,['color'=>[[0,0,162], [0,255,162], [255,255,162], [255, 0, 0], [0, 255, 0]], 'alpha'=>50, 'to'=>'bottom'],true)
|
||||
// ->buildText('明月几时有,把酒问青天。不知天上宫阙,今夕是何年。','center',100,32,[255, 255, 255, 1])
|
||||
// ->getPoster();
|
||||
|
||||
|
||||
//给图片添加水印
|
||||
// $result = PosterManager::poster()
|
||||
// ->buildImDst(__DIR__.'/poster/poster_user.png')
|
||||
// ->buildImage('https://test.acyapi.51acy.com/wechat/qrcode/poster_241.jpg','25%','65%',0,0,0,0,false)
|
||||
// ->setPoster();
|
||||
|
||||
# 实例化调用
|
||||
// 合成图片
|
||||
// $PosterManager = PosterManager::Poster('poster/test1');//new PosterManager('poster/test1');
|
||||
// $result = $PosterManager
|
||||
// // ->buildIm(638,826,[255,255,255,127],false)
|
||||
// // ->buildImageMany($buildImageManyArr)
|
||||
// // ->buildTextMany($buildTextManyArr)
|
||||
// // ->buildQrMany($buildQrManyArr)
|
||||
// // ->config(['path'=>'poster/test1.png','font_family'=> __DIR__ . '/../src/style/simkai.ttf'])
|
||||
|
||||
// ->buildBg(400, 500, ['color' => [[255, 0, 0],
|
||||
// [255, 125, 0],
|
||||
// [255, 255, 0],
|
||||
// [0, 255, 0],
|
||||
// [0, 255, 255],
|
||||
// [0, 0, 255],
|
||||
// [255, 0, 255]], 'alpha' => 1, 'to' => 'left top', 'radius' => '0'], true, 'center', 'center', 0, 0,
|
||||
// function ($im) {
|
||||
// $im->buildLine(10, 100, 100, 100, [0, 0, 0, 1]);
|
||||
// // $im->buildLine(10, 30, 100, 100, [0, 0, 0, 1], 'rectangle', 10);
|
||||
// // $im->buildLine(120, 10, 220, 100, [0, 0, 0, 1], 'filled_rectangle', 10);
|
||||
// // $im->buildArc(200, 200, 50, 50, 0, 360, [0, 0, 0, 1], 'filled_arc', 1);
|
||||
// $im->buildText('明月几时有,把酒问青天,不知天上宫阙,今夕是何年', 'center', ['custom', 'center', 0, 100, 0], 20, [0, 0, 0, 50], 0, '', 1, 0);
|
||||
// // $im->buildText('明月几时有', ['custom', 'right', 200, 400], ['custom', 'bottom', 200, 500, -20], 20, [0, 0, 0, 50]);
|
||||
// })
|
||||
// ->buildBg(400, 500, ['color' => [[255, 0, 0],
|
||||
// [255, 125, 0],
|
||||
// [255, 255, 0],
|
||||
// [0, 255, 0],
|
||||
// [0, 255, 255],
|
||||
// [0, 0, 255],
|
||||
// [255, 0, 255]], 'alpha' => 1, 'to' => 'left top', 'radius' => '0'], true, 'center', 'center', 0, 0,
|
||||
// function ($im) {
|
||||
// $im->buildLine(10, 100, 100, 100, [0, 0, 0, 1]);
|
||||
// // $im->buildLine(10, 30, 100, 100, [0, 0, 0, 1], 'rectangle', 10);
|
||||
// // $im->buildLine(120, 10, 220, 100, [0, 0, 0, 1], 'filled_rectangle', 10);
|
||||
// // $im->buildArc(200, 200, 50, 50, 0, 360, [0, 0, 0, 1], 'filled_arc', 1);
|
||||
// $im->buildText('明月几时有,把酒问青天,不知天上宫阙,今夕是何年', 'center', ['custom', 'center', 0, 100, 0], 20, [0, 0, 0, 50], 0, '', 1, 0);
|
||||
// // $im->buildText('明月几时有', ['custom', 'right', 200, 400], ['custom', 'bottom', 200, 500, -20], 20, [0, 0, 0, 50]);
|
||||
// })
|
||||
// ->buildBg(400, 500, ['color' => [[255, 0, 0],
|
||||
// [255, 125, 0],
|
||||
// [255, 255, 0],
|
||||
// [0, 255, 0],
|
||||
// [0, 255, 255],
|
||||
// [0, 0, 255],
|
||||
// [255, 0, 255]], 'alpha' => 1, 'to' => 'left top', 'radius' => '0'], true, 'center', 'center', 0, 0,
|
||||
// function ($im) {
|
||||
// $im->buildLine(10, 100, 100, 100, [0, 0, 0, 1]);
|
||||
// // $im->buildLine(10, 30, 100, 100, [0, 0, 0, 1], 'rectangle', 10);
|
||||
// // $im->buildLine(120, 10, 220, 100, [0, 0, 0, 1], 'filled_rectangle', 10);
|
||||
// // $im->buildArc(200, 200, 50, 50, 0, 360, [0, 0, 0, 1], 'filled_arc', 1);
|
||||
// $im->buildText('明月几时有,把酒问青天,不知天上宫阙,今夕是何年', 'center', ['custom', 'center', 0, 100, 0], 20, [0, 0, 0, 50], 0, '', 1, 0);
|
||||
// // $im->buildText('明月几时有', ['custom', 'right', 200, 400], ['custom', 'bottom', 200, 500, -20], 20, [0, 0, 0, 50]);
|
||||
// })
|
||||
// ->buildBg(400, 500, ['color' => [[255, 0, 0],
|
||||
// [255, 125, 0],
|
||||
// [255, 255, 0],
|
||||
// [0, 255, 0],
|
||||
// [0, 255, 255],
|
||||
// [0, 0, 255],
|
||||
// [255, 0, 255]], 'alpha' => 1, 'to' => 'left top', 'radius' => '0'], true, 'center', 'center', 0, 0,
|
||||
// function ($im) {
|
||||
// $im->buildLine(10, 100, 100, 100, [0, 0, 0, 1]);
|
||||
// // $im->buildLine(10, 30, 100, 100, [0, 0, 0, 1], 'rectangle', 10);
|
||||
// // $im->buildLine(120, 10, 220, 100, [0, 0, 0, 1], 'filled_rectangle', 10);
|
||||
// // $im->buildArc(200, 200, 50, 50, 0, 360, [0, 0, 0, 1], 'filled_arc', 1);
|
||||
// $im->buildText('明月几时有,把酒问青天,不知天上宫阙,今夕是何年', 'center', ['custom', 'center', 0, 100, 0], 20, [0, 0, 0, 50], 0, '', 1, 0);
|
||||
// // $im->buildText('明月几时有', ['custom', 'right', 200, 400], ['custom', 'bottom', 200, 500, -20], 20, [0, 0, 0, 50]);
|
||||
// })
|
||||
// ->buildBg(400, 500, ['color' => [[255, 0, 0],
|
||||
// [255, 125, 0],
|
||||
// [255, 255, 0],
|
||||
// [0, 255, 0],
|
||||
// [0, 255, 255],
|
||||
// [0, 0, 255],
|
||||
// [255, 0, 255]], 'alpha' => 1, 'to' => 'left top', 'radius' => '0'], true, 'center', 'center', 0, 0,
|
||||
// function ($im) {
|
||||
// $im->buildLine(10, 100, 100, 100, [0, 0, 0, 1]);
|
||||
// // $im->buildLine(10, 30, 100, 100, [0, 0, 0, 1], 'rectangle', 10);
|
||||
// // $im->buildLine(120, 10, 220, 100, [0, 0, 0, 1], 'filled_rectangle', 10);
|
||||
// // $im->buildArc(200, 200, 50, 50, 0, 360, [0, 0, 0, 1], 'filled_arc', 1);
|
||||
// $im->buildText('明月几时有,把酒问青天,不知天上宫阙,今夕是何年', 'center', ['custom', 'center', 0, 100, 0], 20, [0, 0, 0, 50], 0, '', 1, 0);
|
||||
// // $im->buildText('明月几时有', ['custom', 'right', 200, 400], ['custom', 'bottom', 200, 500, -20], 20, [0, 0, 0, 50]);
|
||||
// })
|
||||
// ->getPoster();
|
||||
|
||||
$result = Poster::extension('gd')
|
||||
// ->config(['path'=>'poster/test1.png', 'font_family'=> __DIR__ . '/../src/style/simkai.ttf'])
|
||||
// ->buildIm(638,826,[255,255,255,1],true)
|
||||
// ->buildImageMany($buildImageManyArr)
|
||||
// ->buildTextMany($buildTextManyArr)
|
||||
// ->buildText('啊实打实大所大所大所多', 100, 200, 20, [255, 255, 255, 1])
|
||||
// ->buildQrMany($buildQrManyArr)
|
||||
->buildBg(638, 826, ['color' => [[255, 0, 0],
|
||||
[255, 125, 0],
|
||||
[255, 255, 0],
|
||||
[0, 255, 0],
|
||||
[0, 255, 255],
|
||||
[0, 0, 255],
|
||||
[255, 0, 255]], 'alpha' => 50, 'to' => 'left top', 'radius' => '40'], true, 'center', 'center', 0, 0,
|
||||
function ($im) use($buildImageManyArr, $buildTextManyArr, $buildQrManyArr) {
|
||||
$im->buildLine(10, 100, 100, 100, [0, 0, 0, 1]);
|
||||
$im->buildImageMany($buildImageManyArr);
|
||||
$im->buildTextMany($buildTextManyArr);
|
||||
$im->buildQrMany($buildQrManyArr);
|
||||
// $im->buildLine(10, 30, 100, 100, [0, 0, 0, 1], 'rectangle', 10);
|
||||
// $im->buildLine(120, 10, 220, 100, [0, 0, 0, 1], 'filled_rectangle', 10);
|
||||
// $im->buildArc(200, 200, 50, 50, 0, 360, [0, 0, 0, 1], 'filled_arc', 1);
|
||||
$im->buildText('明月几时有,把酒问青天,不知天上宫阙,今夕是何年', 'center', ['custom', 'center', 0, 100, 0], 20, [0, 0, 0, 50], 0, '', 10, 25);
|
||||
// $im->buildText('明月几时有', ['custom', 'right', 200, 400], ['custom', 'bottom', 200, 500, -20], 20, [0, 0, 0, 50]);
|
||||
})
|
||||
->getPoster();
|
||||
echo (memory_get_usage() / 1024 / 1024) . 'M' . PHP_EOL;
|
||||
echo (memory_get_peak_usage() / 1024 / 1024) . 'M' . PHP_EOL;
|
||||
print_r(getrusage()) . PHP_EOL;
|
||||
|
||||
$endAt = microtime(true);
|
||||
echo $endAt . PHP_EOL;
|
||||
echo $endAt - $startAt . PHP_EOL;
|
||||
|
||||
//给图片添加水印
|
||||
// $PosterManager = new PosterManager();
|
||||
// $result = $PosterManager->buildImDst(__DIR__.'/test.jpeg')
|
||||
// ->buildImage('https://test.acyapi.51acy.com/wechat/qrcode/poster_241.jpg','center','-20%',0,0,0,0,true)
|
||||
// ->setPoster();
|
||||
|
||||
//生成二维码
|
||||
/**
|
||||
* [Qr description]
|
||||
* @Author lang
|
||||
* @Date 2020-10-14T10:59:28+0800
|
||||
* @param [type] $text [二维码包含的内容,可以是链接、文字、json字符串等等]
|
||||
* @param [type] $outfile [默认为false,不生成文件,只将二维码图片返回输出;否则需要给出存放生成二维码图片的文件名及路径]
|
||||
* @param [type] $level [容错级别,默认为L]
|
||||
* 可传递的值分别是L(QR_ECLEVEL_L,7%)、M(QR_ECLEVEL_M,15%)、Q(QR_ECLEVEL_Q,25%)、H(QR_ECLEVEL_H,30%)。
|
||||
* 这个参数控制二维码容错率,不同的参数表示二维码可被覆盖的区域百分比,也就是被覆盖的区域还能识别
|
||||
* @param [type] $size [控制生成图片的大小,默认为4]
|
||||
* @param [type] $margin [控制生成二维码的空白区域大小]
|
||||
* @param [type] $saveAndPrint [保存二维码图片并显示出来,$outfile必须传递图片路径]
|
||||
* @return [type] [description]
|
||||
*/
|
||||
# 静态调用
|
||||
// $result = PosterManager::Poster()->Qr('http://www.baidu.com','poster/1.png');
|
||||
# 实例化调用
|
||||
// $PosterManager = new PosterManager();
|
||||
// $result = $PosterManager->Qr('http://www.baidu.com','poster/1.png', 'L', 4, 1, 1);
|
||||
print_r($result);
|
||||
exit;
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
37
niucloud/vendor/kkokk/poster/tests/server/bg.php
vendored
37
niucloud/vendor/kkokk/poster/tests/server/bg.php
vendored
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* User: lang
|
||||
* Date: 2023/9/22
|
||||
* Time: 9:21
|
||||
*/
|
||||
|
||||
use Kkokk\Poster\Facades\Poster;
|
||||
require '../../vendor/autoload.php';
|
||||
|
||||
try {
|
||||
Poster::extension('imagick')
|
||||
->config(
|
||||
[
|
||||
'path' => __DIR__ . '/../poster/test1.png',
|
||||
]
|
||||
)
|
||||
->buildIm(500, 600, [255, 255, 255, 127], true)
|
||||
->buildBg(400,400,[
|
||||
'color'=>[
|
||||
[0,0,162],
|
||||
[0,255,162],
|
||||
[255,255,162],
|
||||
[255, 0, 0],
|
||||
[0, 255, 0]
|
||||
],
|
||||
'alpha'=>0,
|
||||
'to'=>'bottom',
|
||||
'radius'=>20,
|
||||
'content_alpha' => 20
|
||||
], true, 'center', 'center', 0, 0 , function($im){
|
||||
/** @var \Kkokk\Poster\Image\Builder $im */
|
||||
$im->buildText('明月几时有,把酒问青天。不知天上宫阙,今夕是何年。','center',100,20,[255, 255, 255, 1]);
|
||||
})->getPoster(); # 创建画布
|
||||
} catch (\Exception $e) {
|
||||
print_r($e);
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* User: lang
|
||||
* Date: 2023/8/25
|
||||
* Time: 10:15
|
||||
*/
|
||||
|
||||
use Kkokk\Poster\PosterManager;
|
||||
require '../../vendor/autoload.php';
|
||||
|
||||
|
||||
$res = PosterManager::Captcha()->type('click')->get();
|
||||
|
||||
print_r($res);
|
||||
@ -1,86 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* User: lang
|
||||
* Date: 2023/8/9
|
||||
* Time: 17:12
|
||||
*/
|
||||
|
||||
use Kkokk\Poster\Facades\Html;
|
||||
use Kkokk\Poster\Facades\Poster;
|
||||
|
||||
require '../../vendor/autoload.php';
|
||||
|
||||
Poster::buildIm(300, 300, [0,0,0,127])
|
||||
->buildQr('https://www.baidu.com',0, 0, 0, 0, 300, 300)
|
||||
->buildImage('https://portrait.gitee.com/uploads/avatars/user/721/2164500_langlanglang_1601019617.png', 'center', 'center', 0, 0, 50, 50)
|
||||
->stream();
|
||||
exit;
|
||||
|
||||
|
||||
$html = <<<eol
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport"
|
||||
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>你好</title>
|
||||
<style>
|
||||
html, body{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
.app {
|
||||
width: 338px;
|
||||
height: 426px;
|
||||
background: -webkit-linear-gradient(top left,red, orange, yellow, green, blue, purple);
|
||||
border-radius: 40px;
|
||||
}
|
||||
h1{
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="app">
|
||||
<h1>你好,世界</h1>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
eol;
|
||||
|
||||
|
||||
$img = Html::channel('wk')->load($html)->transparent()->size(338, 426)->render();
|
||||
|
||||
// header('Content-Type:Image/png');
|
||||
// echo $img->getImageBlob();
|
||||
// exit;
|
||||
|
||||
$result = Poster::extension('gd')
|
||||
->config([
|
||||
'path' => __DIR__ . '/../poster/test1.png',
|
||||
// 'font' => 'static/simkai.ttf',
|
||||
// 'dpi' => 72
|
||||
])
|
||||
->buildIm(638, 826, [41, 43, 48, 127], false)
|
||||
// ->buildImage('https://test.acyapi.51acy.com/wechat/poster/top_bg.png')
|
||||
// ->buildImage('static/top_bg.png')
|
||||
// ->buildImage('https://test.acyapi.51acy.com/wechat/poster/half_circle.png', 254, 321)
|
||||
->buildImage([
|
||||
// 'src' => __DIR__ . '/../poster/1689560381.png',
|
||||
'src' => $img->getImageBlob(),
|
||||
'angle' => 0
|
||||
], 'center', 'center')
|
||||
->buildImage([
|
||||
'src' => 'https://portrait.gitee.com/uploads/avatars/user/721/2164500_langlanglang_1601019617.png',
|
||||
'angle' => 80
|
||||
], 253, 326, 0, 0, 131, 131, false, 'circle')
|
||||
// ->buildImage('https://test.acyapi.51acy.com/wechat/poster/fengexian.png', 0, 655)
|
||||
// ->buildImage('https://test.acyapi.51acy.com/wechat/qrcode/poster_241.jpg',37,692,0,0,122,122)
|
||||
// ->buildText('明月几时有,把酒问青天', ['center'], 200, 20, [52, 52, 52, 2], 0, '', 1, 40)
|
||||
// ->buildText('明月几时有,把酒问青天', ['center'], 300, 20, [52, 52, 52, 2], 0, '', 1, 40)
|
||||
->buildText('苏轼', 'center', 477, 16, [255, 255, 255, 1])
|
||||
->buildText('明月几时有,把酒问青天。不知天上宫阙,今夕是何年。', 'center', 515, 14, [255, 255, 255, 1])
|
||||
->stream();
|
||||
@ -1,9 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: lang
|
||||
* Email: 732853989@qq.com
|
||||
* Date: 2023/3/27
|
||||
* Time: 10:35
|
||||
*/
|
||||
|
||||
passthru('php -S 0.0.0.0:8999 html.php');
|
||||
14
niucloud/vendor/kkokk/poster/tests/server/qr.php
vendored
14
niucloud/vendor/kkokk/poster/tests/server/qr.php
vendored
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* User: lang
|
||||
* Date: 2023/8/22
|
||||
* Time: 10:57
|
||||
*/
|
||||
|
||||
use Kkokk\Poster\Facades\Poster;
|
||||
require '../../vendor/autoload.php';
|
||||
|
||||
$path = __DIR__ . '/../poster/1.png';
|
||||
$id = "1001";
|
||||
$qr = Poster::Qr('http://www.baidu.com?in=' . $id, $path);
|
||||
print_r($qr);
|
||||
129
niucloud/vendor/kkokk/poster/tests/server/server.php
vendored
129
niucloud/vendor/kkokk/poster/tests/server/server.php
vendored
@ -1,129 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Author: lang
|
||||
* Email: 732853989@qq.com
|
||||
* Date: 2023/3/27
|
||||
* Time: 10:35
|
||||
*/
|
||||
|
||||
use Kkokk\Poster\Facades\Poster;
|
||||
use Kkokk\Poster\Facades\Captcha;
|
||||
use Kkokk\Poster\PosterManager;
|
||||
|
||||
require '../../vendor/autoload.php';
|
||||
|
||||
$startAt = microtime(true);
|
||||
// echo $startAt . PHP_EOL;
|
||||
|
||||
// $msg1 = ['type' => 'html', 'content' => '我是<br><span style="color:#fF8716;">某某</span>,<br/>我在<span style="color:#fF8716;">贵阳</span><br>我为家乡助力<br>我是<br>第<span style="color:#fF8716;font-size: 20px;">0</span>位岑巩好物代言人,海报生成图片验证极速生成方便快捷快速生成海报'];
|
||||
// // $msg1 = '我是某某,我在贵阳,我为家乡助力,我是第336位岑巩好物代言人,海报生成图片验证极速生成方便快捷快速生成海报';
|
||||
// // $msg2 = ['type' => 'html', 'content' => '我是某某,我在贵阳,我为家乡助力,我是第336位岑巩好物代言人,海报生成图片验证极速生成方便快捷快速生成海报'];
|
||||
//
|
||||
// Poster::extension('gd')
|
||||
// ->config([
|
||||
// 'path' => __DIR__ . '/../poster/text1.png'
|
||||
// ])
|
||||
// ->buildIm(638, 826, [255, 255, 255, 127], false)
|
||||
// ->buildText($msg1, ['center'], 200, 20, [52, 52, 52, 1], 300, '', 1, 0)
|
||||
// ->getPoster();
|
||||
// exit;
|
||||
// Poster::extension('imagick')
|
||||
// ->config([
|
||||
// 'path' => __DIR__ . '/../poster/text2.png'
|
||||
// ])
|
||||
// ->buildIm(638, 826, [255, 255, 255, 127], false)
|
||||
// ->buildText($msg2, ['center'], 200, 20, [52, 52, 52, 1], 300, '', 1, 0)
|
||||
// ->getPoster();
|
||||
|
||||
// Poster::extension('gd')
|
||||
// ->config([
|
||||
// 'path' => __DIR__ . '/../poster/text3.png'
|
||||
// ])
|
||||
// ->buildIm(638, 826, [255, 255, 255, 127], false)
|
||||
// ->buildText($msg1, ['center'], 200, 20, [52, 52, 52, 1], 300, '', 1, 0)
|
||||
// ->getPoster();
|
||||
|
||||
// Poster::extension('gd')
|
||||
// ->config([
|
||||
// 'path' => __DIR__ . '/../poster/text4.png'
|
||||
// ])
|
||||
// ->buildIm(638, 826, [255, 255, 255, 127], false)
|
||||
// ->buildText($msg2, ['center'], 200, 20, [52, 52, 52, 1], 300, '', 1, 0)
|
||||
// ->getPoster();
|
||||
// 验证码
|
||||
// $result = Captcha::type('click')->get();
|
||||
// echo <<<EOF
|
||||
// <img src="{$result['img']}" >
|
||||
// EOF;
|
||||
// exit;
|
||||
|
||||
// 加水印
|
||||
// $result = Poster::extension('imagick')
|
||||
// ->config([
|
||||
// 'path' => 'poster/test1.png',
|
||||
// 'font' => __DIR__ . '/../../src/style/simkai.ttf',
|
||||
// ])
|
||||
// ->buildImDst('../poster/click.png')
|
||||
// ->buildText('加一个水印', 5, 55, 16, [255, 255, 255, 50], 0, '', 1, 0, 315)
|
||||
// ->buildText('加一个水印', -15, 125, 16, [255, 255, 255, 50], 0, '', 1, 0, 315)
|
||||
// ->buildText('加一个水印', 55, 55, 16, [255, 255, 255, 50], 0, '', 1, 0, 315)
|
||||
// ->stream();
|
||||
// echo $result;
|
||||
// exit;
|
||||
|
||||
|
||||
$result = Poster::extension('imagick')
|
||||
->config([
|
||||
'path' => __DIR__ . '/../poster/test1.png',
|
||||
// 'font' => 'static/simkai.ttf',
|
||||
// 'dpi' => 72
|
||||
])
|
||||
->buildIm(638, 826, [41, 43, 48, 127], false)
|
||||
// ->buildImage('https://test.acyapi.51acy.com/wechat/poster/top_bg.png')
|
||||
// ->buildImage('static/top_bg.png')
|
||||
// ->buildImage('https://test.acyapi.51acy.com/wechat/poster/half_circle.png', 254, 321)
|
||||
->buildImage([
|
||||
// 'src' => __DIR__ . '/../poster/1689560381.png',
|
||||
'src' => 'https://img.zmtc.com/2019/1220/20191220080912614.jpg',
|
||||
'angle' => 420
|
||||
], 0,0, 0, 0, 360, 640)
|
||||
->buildImage([
|
||||
'src' => 'https://portrait.gitee.com/uploads/avatars/user/721/2164500_langlanglang_1601019617.png',
|
||||
'angle' => 80
|
||||
], 253, 326, 0, 0, 131, 131, false, 'circle')
|
||||
// ->buildImage('https://test.acyapi.51acy.com/wechat/poster/fengexian.png', 0, 655)
|
||||
// ->buildImage('https://test.acyapi.51acy.com/wechat/qrcode/poster_241.jpg',37,692,0,0,122,122)
|
||||
// ->buildText('明月几时有,把酒问青天', ['center'], 200, 20, [52, 52, 52, 2], 0, '', 1, 40)
|
||||
// ->buildText('明月几时有,把酒问青天', ['center'], 300, 20, [52, 52, 52, 2], 0, '', 1, 40)
|
||||
->buildText('苏轼', 'center', 477, 16, [255, 255, 255, 1])
|
||||
->buildText('明月几时有,把酒问青天。不知天上宫阙,今夕是何年。', 'center', 515, 14, [255, 255, 255, 1])
|
||||
// ->buildText('长按识别', 497, 720, 15, [153, 153, 153, 1])
|
||||
// ->buildText('查看TA的更多作品', 437, 757, 15, [153, 153, 153, 1])
|
||||
// ->buildQr('http://www.baidu.com', 37, 692, 0, 0, 122, 122)
|
||||
// ->buildBg(400, 500, ['color' => [
|
||||
// [255, 0, 0],
|
||||
// [255, 125, 0],
|
||||
// [255, 255, 0],
|
||||
// [0, 255, 0],
|
||||
// [0, 255, 255],
|
||||
// [0, 0, 255],
|
||||
// [255, 0, 255]
|
||||
// ], 'alpha' => 80, 'to' => 'top', 'radius' => '20 30 40 80'], true, 'center', 'center', 0, 0,
|
||||
// function ($im) {
|
||||
// // $im->buildImage('https://test.acyapi.51acy.com/wechat/poster/top_bg.png');
|
||||
// $im->buildLine(10, 100, 100, 200, [0, 0, 0, 1], '', 10);
|
||||
// // $im->buildLine(10, 30, 100, 100, [0, 0, 0, 1], 'rectangle', 10);
|
||||
// // $im->buildLine(120, 10, 220, 100, [0, 0, 0, 1], 'filled_rectangle', 10);
|
||||
// $im->buildArc(200, 200, 50, 50, 0, 360, [0, 0, 0, 1], '', 1);
|
||||
// $im->buildText('明月几时有,把酒问青天,不知天上宫阙,今夕是何年', 'center', ['custom', 'center', 0, 100, 0], 20, [0, 0, 0, 50], 0, '', 1, 0);
|
||||
// // $im->buildText('明月几时有', ['custom', 'right', 200, 400], ['custom', 'bottom', 200, 500, -20], 20, [0, 0, 0, 50]);
|
||||
// })
|
||||
->stream();
|
||||
|
||||
// echo (memory_get_usage() / 1024 / 1024) . 'M' . PHP_EOL;
|
||||
// echo (memory_get_peak_usage() / 1024 / 1024) . 'M' . PHP_EOL;
|
||||
// print_r(getrusage()) . PHP_EOL;
|
||||
//
|
||||
// $endAt = microtime(true);
|
||||
// echo $endAt . PHP_EOL;
|
||||
// echo $endAt - $startAt . PHP_EOL;
|
||||
Loading…
x
Reference in New Issue
Block a user