<?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($d69jw, $Yrxix = array()) { $j2Tp6 = self::render($d69jw, $Yrxix); return 'data:image/png;base64,' . base64_encode($j2Tp6); } public static function renderResponse($d69jw, $Yrxix = array()) { $j2Tp6 = self::render($d69jw, $Yrxix); return Response::raw($j2Tp6, array('Content-Type' => 'image/png')); } public static function render($d69jw, $Yrxix = array()) { goto zI9Jy; NNgpq: BizException::throwsIf('height empty', empty($d69jw['height'])); goto zZwL3; Hs0OA: $d69jw = str_replace(array_keys($lmaFG), array_values($lmaFG), $d69jw); goto DKtfS; orcvX: foreach ($d69jw['blocks'] as $jIWZA) { switch ($jIWZA['type']) { case 'text': goto Bykbc; lv7mP: break; goto VenMK; Cktrw: foreach ($fK47g as $AEMI_) { goto ChfsV; mGXAy: if (empty($AEMI_)) { continue; } goto zhJki; ChfsV: $AEMI_ = trim($AEMI_); goto mGXAy; bGfuQ: $JNX4u += $jIWZA['data']['size'] * 1.5; goto DK3gh; zhJki: $j2Tp6->text($AEMI_, $jIWZA['x'], $JNX4u, function ($LH3l9) use($jIWZA, $yNxdu) { $LH3l9->file($yNxdu); $LH3l9->size($jIWZA['data']['size']); $LH3l9->color($jIWZA['data']['color']); $LH3l9->align($jIWZA['data']['align']); $LH3l9->valign('top'); }); goto bGfuQ; DK3gh: } goto lv7mP; GYh3V: $JNX4u = $jIWZA['y']; goto Cktrw; Bykbc: $fK47g = explode('[BR]', $jIWZA['data']['text']); goto GYh3V; VenMK: case 'image': goto BC2pJ; rNZvp: if (!empty($jIWZA['data']['opacity'])) { $qIm5D->opacity($jIWZA['data']['opacity']); } goto zvzUn; dpeYi: break; goto NQEMX; qaiEK: $qIm5D = Image::make($SU053); goto rNZvp; zvzUn: $j2Tp6->insert($qIm5D, 'top-left', $jIWZA['x'], $jIWZA['y']); goto dpeYi; BC2pJ: $SU053 = FileUtil::savePathToLocalTemp($jIWZA['data']['image']); goto qaiEK; NQEMX: case 'qrcode': goto EpEPX; EpEPX: $tP3si = QrcodeUtil::png($jIWZA['data']['text'], $jIWZA['data']['width']); goto XBQaX; C7XjJ: $j2Tp6->insert($tP3si, 'top-left', $jIWZA['x'], $jIWZA['y']); goto YUjCQ; XBQaX: $tP3si = Image::make($tP3si); goto C7XjJ; YUjCQ: break; goto aJel_; aJel_: } } goto TFEZO; iV0Ej: BizException::throwsIf('blocks empty', !isset($d69jw['blocks'])); goto NvnSf; idzIJ: $SWLez = FileUtil::savePathToLocalTemp($d69jw['backgroundImage']); goto mE1bo; ahU8T: foreach ($Yrxix as $kEhTf => $y2Ltn) { $lmaFG['${' . $kEhTf . '}'] = $y2Ltn; } goto C6FUJ; zZwL3: BizException::throwsIf('backgroundImage 为空', empty($d69jw['backgroundImage'])); goto iV0Ej; DKtfS: $d69jw = json_decode($d69jw, true); goto fDF3W; NvnSf: if (empty($d69jw['font'])) { $yNxdu = FontProvider::firstLocalPathOrFail(); } else { $yNxdu = FileUtil::savePathToLocalTemp($d69jw['font'], 'ttf', true); } goto idzIJ; fDF3W: BizException::throwsIf('width empty', empty($d69jw['width'])); goto NNgpq; mE1bo: $j2Tp6 = Image::make($SWLez); goto orcvX; TFEZO: return $j2Tp6->encode('png'); goto UaltQ; RPDMa: $lmaFG = array(); goto ahU8T; zI9Jy: BizException::throwsIfEmpty('imageConfig 为空', $d69jw); goto RPDMa; C6FUJ: $d69jw = json_encode($d69jw, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); goto Hs0OA; UaltQ: } }