<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\QuickRun\ImageDesign; use Intervention\Image\Facades\Image; use ModStart\Core\Exception\BizException; use ModStart\Core\Input\Response; use ModStart\Core\Provider\FontProvider; use ModStart\Core\Util\FileUtil; use ModStart\Core\Util\QrcodeUtil; class ImageDesignUtil { public static function renderBase64DataString($hObR3, $UcXEZ = array()) { $S5EW1 = self::render($hObR3, $UcXEZ); return 'data:image/png;base64,' . base64_encode($S5EW1); } public static function renderResponse($hObR3, $UcXEZ = array()) { $S5EW1 = self::render($hObR3, $UcXEZ); return Response::raw($S5EW1, array('Content-Type' => 'image/png')); } public static function render($hObR3, $UcXEZ = array()) { goto R4v3f; VSOh_: BizException::throwsIf('height empty', empty($hObR3['height'])); goto JGmuo; JGmuo: BizException::throwsIf('backgroundImage 为空', empty($hObR3['backgroundImage'])); goto mgej3; Oi6eg: $vjpOx = FileUtil::savePathToLocalTemp($hObR3['backgroundImage']); goto YpzHP; cXpQL: return $S5EW1->encode('png'); goto VP07J; ChnRA: $hObR3 = str_replace(array_keys($NlJvy), array_values($NlJvy), $hObR3); goto aLpx5; aLpx5: $hObR3 = json_decode($hObR3, true); goto rQIbi; rQIbi: BizException::throwsIf('width empty', empty($hObR3['width'])); goto VSOh_; R4v3f: BizException::throwsIfEmpty('imageConfig 为空', $hObR3); goto pdvJG; NatwG: $hObR3 = json_encode($hObR3, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); goto ChnRA; qQGs8: if (empty($hObR3['font'])) { $arenI = FontProvider::firstLocalPathOrFail(); } else { $arenI = FileUtil::savePathToLocalTemp($hObR3['font'], 'ttf', true); } goto Oi6eg; mgej3: BizException::throwsIf('blocks empty', !isset($hObR3['blocks'])); goto qQGs8; YpzHP: $S5EW1 = Image::make($vjpOx); goto TI3nR; pdvJG: $NlJvy = array(); goto lvrKi; lvrKi: foreach ($UcXEZ as $ynzcc => $nfRLq) { $NlJvy['${' . $ynzcc . '}'] = $nfRLq; } goto NatwG; TI3nR: foreach ($hObR3['blocks'] as $kHxHl) { switch ($kHxHl['type']) { case 'text': goto g_XBd; u9DPF: $CKXyK = $kHxHl['y']; goto ZFCTt; g_XBd: $N2dbO = explode('[BR]', $kHxHl['data']['text']); goto u9DPF; pQW5d: break; goto RYlQ4; ZFCTt: foreach ($N2dbO as $U3uds) { goto EHVZW; f8Ocx: $S5EW1->text($U3uds, $kHxHl['x'], $CKXyK, function ($MJLbU) use($kHxHl, $arenI) { $MJLbU->file($arenI); $MJLbU->size($kHxHl['data']['size']); $MJLbU->color($kHxHl['data']['color']); $MJLbU->align($kHxHl['data']['align']); $MJLbU->valign('top'); }); goto wIMKt; EHVZW: $U3uds = trim($U3uds); goto BQhEk; wIMKt: $CKXyK += $kHxHl['data']['size'] * 1.5; goto LdxHn; BQhEk: if (empty($U3uds)) { continue; } goto f8Ocx; LdxHn: } goto pQW5d; RYlQ4: case 'image': goto cA71h; B9szE: break; goto S8GY6; eiJU3: $S5EW1->insert($zN13V, 'top-left', $kHxHl['x'], $kHxHl['y']); goto B9szE; zbVrA: $zN13V = Image::make($qBOjq); goto L01Y7; cA71h: $qBOjq = FileUtil::savePathToLocalTemp($kHxHl['data']['image']); goto zbVrA; L01Y7: if (!empty($kHxHl['data']['opacity'])) { $zN13V->opacity($kHxHl['data']['opacity']); } goto eiJU3; S8GY6: case 'qrcode': goto zf0tD; zf0tD: $h74SG = QrcodeUtil::png($kHxHl['data']['text'], $kHxHl['data']['width']); goto ocGKR; ocGKR: $h74SG = Image::make($h74SG); goto HJO1L; FOxUc: break; goto fMu5q; HJO1L: $S5EW1->insert($h74SG, 'top-left', $kHxHl['x'], $kHxHl['y']); goto FOxUc; fMu5q: } } goto cXpQL; VP07J: } }