作者 何书鹏
1 个管道 的构建 通过 耗费 1 秒

二开海报

... ... @@ -455,28 +455,43 @@ class Index extends Api
$w = $box1_maxx - $box1_minx;
$box1_minx += ($image->width() - $w) / 2;
// 备注居中
$last_text = '码上报名';
$box2 = imagettfbbox($size, 0, $path_ttf, $last_text);
// 工价
$size_11 = 11;
$factory_price_total = '工价:'.$job['factory_price_total'].'元/小时';
$box2 = imagettfbbox($size_11, 0, $path_ttf, $factory_price_total);
$box2_minx = min($box2[0], $box2[2], $box2[4], $box2[6]);
$box2_maxx = max($box2[0], $box2[2], $box2[4], $box2[6]);
/* 计算文字初始坐标和尺寸 */
$w = $box2_maxx - $box2_minx;
$box2_minx += ($image->width() - $w) / 2;
$box2_minx += $image->width() - $w - 57;
// 工价、工资
$factory_price_total = '工价:'.$job['factory_price_total'].'元/小时';
// 工资
$salary = '工资:'.$job['salary'].'元/月';
$box3 = imagettfbbox($size_11, 0, $path_ttf, $salary);
$box3_minx = min($box3[0], $box3[2], $box3[4], $box3[6]);
$box3_maxx = max($box3[0], $box3[2], $box3[4], $box3[6]);
/* 计算文字初始坐标和尺寸 */
$w = $box3_maxx - $box3_minx;
$box3_minx += $image->width() - $w - 57;
// 备注居中
$last_text = '码上报名';
$box4 = imagettfbbox($size, 0, $path_ttf, $last_text);
$box4_minx = min($box4[0], $box4[2], $box4[4], $box4[6]);
$box4_maxx = max($box4[0], $box4[2], $box4[4], $box4[6]);
/* 计算文字初始坐标和尺寸 */
$w = $box4_maxx - $box4_minx;
$box4_minx += ($image->width() - $w) / 2;
$image->water($job_image,[12,12])
->text($job['job_name'],$path_ttf,$size,'#323233',[$box1_minx,205])
->text($job['job_name'],$path_ttf,$size,'#323233',[$box1_minx+1,205]) //画两遍,加粗
->text($factory_price_total,$path_ttf,11,'#323233',[178,238])
->text($factory_price_total,$path_ttf,11,'#323233',[179,238])
->text($salary,$path_ttf,11,'#323233',[137,266])
->text($salary,$path_ttf,11,'#323233',[138,266])
->text($last_text,$path_ttf,$size,'#FE9515',[$box2_minx,322])
->text($last_text,$path_ttf,$size,'#FE9515',[$box2_minx+1,322])
->text($factory_price_total,$path_ttf,$size_11,'#323233',[$box2_minx,238])
->text($factory_price_total,$path_ttf,$size_11,'#323233',[$box2_minx+1,238])
->text($salary,$path_ttf,$size_11,'#323233',[$box3_minx,266])
->text($salary,$path_ttf,$size_11,'#323233',[$box3_minx+1,266])
->text($last_text,$path_ttf,$size,'#FE9515',[$box4_minx,322])
->text($last_text,$path_ttf,$size,'#FE9515',[$box4_minx+1,322])
->water($qrcode,[124,349])
->save($filename);
$url = request()->domain().'/'.$filename.'?v='.time();
... ...