<?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($dC69m, $euKXb = array()) { $ecdK2 = self::render($dC69m, $euKXb); return 'data:image/png;base64,' . base64_encode($ecdK2); } public static function renderResponse($dC69m, $euKXb = array()) { $ecdK2 = self::render($dC69m, $euKXb); return Response::raw($ecdK2, array('Content-Type' => 'image/png')); } public static function render($dC69m, $euKXb = array()) { goto P2wR1; DNsj0: if (empty($dC69m['font'])) { $i7Fh3 = FontProvider::firstLocalPathOrFail(); } else { $i7Fh3 = FileUtil::savePathToLocalTemp($dC69m['font'], 'ttf', true); } goto BuSO5; T_mGE: foreach ($euKXb as $F4wee => $SxG_W) { $yoUS2['${' . $F4wee . '}'] = $SxG_W; } goto m2kWd; sWvVu: BizException::throwsIf('blocks empty', !isset($dC69m['blocks'])); goto DNsj0; NLDnM: $ecdK2 = Image::make($ru73J); goto R4gvg; ts5wC: $yoUS2 = array(); goto T_mGE; Hq1fJ: $dC69m = str_replace(array_keys($yoUS2), array_values($yoUS2), $dC69m); goto PWpxH; R4gvg: foreach ($dC69m['blocks'] as $MNZ1i) { switch ($MNZ1i['type']) { case 'text': goto Z_zva; S0Xap: break; goto F1FYs; LGN0t: foreach ($DMdTH as $yEc2N) { goto SxStA; wzM7U: $ecdK2->text($yEc2N, $MNZ1i['x'], $OaYtH, function ($dC3So) use($MNZ1i, $i7Fh3) { $dC3So->file($i7Fh3); $dC3So->size($MNZ1i['data']['size']); $dC3So->color($MNZ1i['data']['color']); $dC3So->align($MNZ1i['data']['align']); $dC3So->valign('top'); }); goto ubLkY; N13V1: if (empty($yEc2N)) { continue; } goto wzM7U; SxStA: $yEc2N = trim($yEc2N); goto N13V1; ubLkY: $OaYtH += $MNZ1i['data']['size'] * 1.5; goto mq8xq; mq8xq: } goto S0Xap; Z_zva: $DMdTH = explode('[BR]', $MNZ1i['data']['text']); goto QZuNN; QZuNN: $OaYtH = $MNZ1i['y']; goto LGN0t; F1FYs: case 'image': goto HBGV1; sb3x2: break; goto uIYRN; fXCp0: if (!empty($MNZ1i['data']['opacity'])) { $nRb5l->opacity($MNZ1i['data']['opacity']); } goto D95FD; HBGV1: $ffltm = FileUtil::savePathToLocalTemp($MNZ1i['data']['image']); goto x_AeT; D95FD: $ecdK2->insert($nRb5l, 'top-left', $MNZ1i['x'], $MNZ1i['y']); goto sb3x2; x_AeT: $nRb5l = Image::make($ffltm); goto fXCp0; uIYRN: case 'qrcode': goto ySnyJ; OC_27: break; goto wkegY; ySnyJ: $rzPAQ = QrcodeUtil::png($MNZ1i['data']['text'], $MNZ1i['data']['width']); goto dfOKE; TZvSg: $ecdK2->insert($rzPAQ, 'top-left', $MNZ1i['x'], $MNZ1i['y']); goto OC_27; dfOKE: $rzPAQ = Image::make($rzPAQ); goto TZvSg; wkegY: } } goto VswJs; m2kWd: $dC69m = json_encode($dC69m, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); goto Hq1fJ; jztOn: BizException::throwsIf('height empty', empty($dC69m['height'])); goto lMQjW; lMQjW: BizException::throwsIf('backgroundImage 为空', empty($dC69m['backgroundImage'])); goto sWvVu; VswJs: return $ecdK2->encode('png'); goto XSCuf; P2wR1: BizException::throwsIfEmpty('imageConfig 为空', $dC69m); goto ts5wC; PWpxH: $dC69m = json_decode($dC69m, true); goto ckp3b; BuSO5: $ru73J = FileUtil::savePathToLocalTemp($dC69m['backgroundImage']); goto NLDnM; ckp3b: BizException::throwsIf('width empty', empty($dC69m['width'])); goto jztOn; XSCuf: } }