<?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($Tld20, $olGRi = array()) { $CzRaU = self::render($Tld20, $olGRi); return 'data:image/png;base64,' . base64_encode($CzRaU); } public static function renderResponse($Tld20, $olGRi = array()) { $CzRaU = self::render($Tld20, $olGRi); return Response::raw($CzRaU, array('Content-Type' => 'image/png')); } public static function render($Tld20, $olGRi = array()) { goto IAKFS; eRbQj: foreach ($Tld20['blocks'] as $Z32UA) { switch ($Z32UA['type']) { case 'text': goto qiGJi; flUaM: $pRxN5 = $Z32UA['y']; goto RDAq3; RDAq3: foreach ($QmJ_1 as $SZ55E) { goto wyJkh; VFnXk: $CzRaU->text($SZ55E, $Z32UA['x'], $pRxN5, function ($BOQL8) use($Z32UA, $lajKk) { $BOQL8->file($lajKk); $BOQL8->size($Z32UA['data']['size']); $BOQL8->color($Z32UA['data']['color']); $BOQL8->align($Z32UA['data']['align']); $BOQL8->valign('top'); }); goto qc13s; wyJkh: $SZ55E = trim($SZ55E); goto WycSp; qc13s: $pRxN5 += $Z32UA['data']['size'] * 1.5; goto S2uc7; WycSp: if (empty($SZ55E)) { continue; } goto VFnXk; S2uc7: } goto etdlI; qiGJi: $QmJ_1 = explode('[BR]', $Z32UA['data']['text']); goto flUaM; etdlI: break; goto noRYV; noRYV: case 'image': goto TCqLF; TCqLF: $gcMJa = FileUtil::savePathToLocalTemp($Z32UA['data']['image']); goto JvdhH; vKX4Q: break; goto P_R8v; JvdhH: $BDfUo = Image::make($gcMJa); goto OB8wn; gVcGX: $CzRaU->insert($BDfUo, 'top-left', $Z32UA['x'], $Z32UA['y']); goto vKX4Q; OB8wn: if (!empty($Z32UA['data']['opacity'])) { $BDfUo->opacity($Z32UA['data']['opacity']); } goto gVcGX; P_R8v: case 'qrcode': goto YmyKH; YmyKH: $FLdjv = QrcodeUtil::png($Z32UA['data']['text'], $Z32UA['data']['width']); goto qlVG2; qlVG2: $FLdjv = Image::make($FLdjv); goto dyVvI; oKRPo: break; goto CCcvC; dyVvI: $CzRaU->insert($FLdjv, 'top-left', $Z32UA['x'], $Z32UA['y']); goto oKRPo; CCcvC: } } goto VbnaV; kH3tl: foreach ($olGRi as $MFVkb => $YxV2x) { $FU4s0['${' . $MFVkb . '}'] = $YxV2x; } goto Sg_NJ; ZKNu1: $v9UJW = FileUtil::savePathToLocalTemp($Tld20['backgroundImage']); goto UmPNz; VbnaV: return $CzRaU->encode('png'); goto Uyy_R; UmPNz: $CzRaU = Image::make($v9UJW); goto eRbQj; m9D4C: if (empty($Tld20['font'])) { $lajKk = FontProvider::firstLocalPathOrFail(); } else { $lajKk = FileUtil::savePathToLocalTemp($Tld20['font'], 'ttf', true); } goto ZKNu1; GJ9mL: BizException::throwsIf('width empty', empty($Tld20['width'])); goto h8VWy; kPS0W: $Tld20 = str_replace(array_keys($FU4s0), array_values($FU4s0), $Tld20); goto BQ02p; BQ02p: $Tld20 = json_decode($Tld20, true); goto GJ9mL; Sg_NJ: $Tld20 = json_encode($Tld20, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); goto kPS0W; uOHay: BizException::throwsIf('blocks empty', !isset($Tld20['blocks'])); goto m9D4C; IAKFS: BizException::throwsIfEmpty('imageConfig 为空', $Tld20); goto ELfR0; ELfR0: $FU4s0 = array(); goto kH3tl; leNLV: BizException::throwsIf('backgroundImage 为空', empty($Tld20['backgroundImage'])); goto uOHay; h8VWy: BizException::throwsIf('height empty', empty($Tld20['height'])); goto leNLV; Uyy_R: } }