<?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($PEG0w, $JMqy7 = array()) { $dpsOl = self::render($PEG0w, $JMqy7); return 'data:image/png;base64,' . base64_encode($dpsOl); } public static function renderResponse($PEG0w, $JMqy7 = array()) { $dpsOl = self::render($PEG0w, $JMqy7); return Response::raw($dpsOl, array('Content-Type' => 'image/png')); } public static function render($PEG0w, $JMqy7 = array()) { goto Jbu6A; dY7bB: $NtthH = array(); goto LolxV; nTGb3: if (empty($PEG0w['font'])) { $BEbUI = FontProvider::firstLocalPathOrFail(); } else { $BEbUI = FileUtil::savePathToLocalTemp($PEG0w['font'], 'ttf', true); } goto y_LMd; Uv_U3: foreach ($PEG0w['blocks'] as $vPOhn) { switch ($vPOhn['type']) { case 'text': goto B5DaD; YvOaI: foreach ($yCYNK as $eNUnj) { goto Ah_ka; ceCzp: if (empty($eNUnj)) { continue; } goto PaAFh; AQuVB: $AXxQ2 += $vPOhn['data']['size'] * 1.5; goto P3fAX; PaAFh: $dpsOl->text($eNUnj, $vPOhn['x'], $AXxQ2, function ($TLyCi) use($vPOhn, $BEbUI) { $TLyCi->file($BEbUI); $TLyCi->size($vPOhn['data']['size']); $TLyCi->color($vPOhn['data']['color']); $TLyCi->align($vPOhn['data']['align']); $TLyCi->valign('top'); }); goto AQuVB; Ah_ka: $eNUnj = trim($eNUnj); goto ceCzp; P3fAX: } goto pzJsv; B5DaD: $yCYNK = explode('[BR]', $vPOhn['data']['text']); goto GHyfn; GHyfn: $AXxQ2 = $vPOhn['y']; goto YvOaI; pzJsv: break; goto xZqhr; xZqhr: case 'image': goto dFBjf; cdhwO: break; goto CJU5f; qEul_: $Qy07b = Image::make($rynxm); goto W45KK; W45KK: if (!empty($vPOhn['data']['opacity'])) { $Qy07b->opacity($vPOhn['data']['opacity']); } goto SKYqY; SKYqY: $dpsOl->insert($Qy07b, 'top-left', $vPOhn['x'], $vPOhn['y']); goto cdhwO; dFBjf: $rynxm = FileUtil::savePathToLocalTemp($vPOhn['data']['image']); goto qEul_; CJU5f: case 'qrcode': goto ojQoV; ojQoV: $o3_sF = QrcodeUtil::png($vPOhn['data']['text'], $vPOhn['data']['width']); goto nWyTQ; VO8A1: $dpsOl->insert($o3_sF, 'top-left', $vPOhn['x'], $vPOhn['y']); goto hNX3_; hNX3_: break; goto JJNb0; nWyTQ: $o3_sF = Image::make($o3_sF); goto VO8A1; JJNb0: } } goto wbnBC; HHR9X: $dpsOl = Image::make($Kq3gD); goto Uv_U3; wbnBC: return $dpsOl->encode('png'); goto gGqW4; LolxV: foreach ($JMqy7 as $JdFJR => $PSYn9) { $NtthH['${' . $JdFJR . '}'] = $PSYn9; } goto YW8Wl; ckk3Q: BizException::throwsIf('blocks empty', !isset($PEG0w['blocks'])); goto nTGb3; vWM9C: $PEG0w = str_replace(array_keys($NtthH), array_values($NtthH), $PEG0w); goto oDmMq; Jbu6A: BizException::throwsIfEmpty('imageConfig 为空', $PEG0w); goto dY7bB; oDmMq: $PEG0w = json_decode($PEG0w, true); goto iiHdp; x3cq1: BizException::throwsIf('backgroundImage 为空', empty($PEG0w['backgroundImage'])); goto ckk3Q; iiHdp: BizException::throwsIf('width empty', empty($PEG0w['width'])); goto S8xvj; y_LMd: $Kq3gD = FileUtil::savePathToLocalTemp($PEG0w['backgroundImage']); goto HHR9X; YW8Wl: $PEG0w = json_encode($PEG0w, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); goto vWM9C; S8xvj: BizException::throwsIf('height empty', empty($PEG0w['height'])); goto x3cq1; gGqW4: } }