<?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($m6H3T, $j5r5q = array()) { $uKj64 = self::render($m6H3T, $j5r5q); return 'data:image/png;base64,' . base64_encode($uKj64); } public static function renderResponse($m6H3T, $j5r5q = array()) { $uKj64 = self::render($m6H3T, $j5r5q); return Response::raw($uKj64, array('Content-Type' => 'image/png')); } public static function render($m6H3T, $j5r5q = array()) { goto lqVKF; HttwN: $m6H3T = str_replace(array_keys($DaPqY), array_values($DaPqY), $m6H3T); goto MGWXB; pAAVq: BizException::throwsIf('height empty', empty($m6H3T['height'])); goto KKDtk; hYbNI: return $uKj64->encode('png'); goto pQqJj; UlVh8: if (empty($m6H3T['font'])) { $q4AMH = FontProvider::firstLocalPathOrFail(); } else { $q4AMH = FileUtil::savePathToLocalTemp($m6H3T['font'], 'ttf', true); } goto aRgdl; EfSav: $uKj64 = Image::make($VmHM0); goto WSPcb; KKDtk: BizException::throwsIf('backgroundImage 为空', empty($m6H3T['backgroundImage'])); goto AT0dw; VMdOG: $m6H3T = json_encode($m6H3T, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); goto HttwN; ZbwBg: BizException::throwsIf('width empty', empty($m6H3T['width'])); goto pAAVq; AT0dw: BizException::throwsIf('blocks empty', !isset($m6H3T['blocks'])); goto UlVh8; WSPcb: foreach ($m6H3T['blocks'] as $FSL7c) { switch ($FSL7c['type']) { case 'text': goto rOM9A; WLSdM: $x8CeK = $FSL7c['y']; goto N2dty; N2dty: foreach ($fNt64 as $Sa90h) { goto lSO_i; J7C9s: if (empty($Sa90h)) { continue; } goto InomD; lSO_i: $Sa90h = trim($Sa90h); goto J7C9s; InomD: $uKj64->text($Sa90h, $FSL7c['x'], $x8CeK, function ($Gm9Pc) use($FSL7c, $q4AMH) { $Gm9Pc->file($q4AMH); $Gm9Pc->size($FSL7c['data']['size']); $Gm9Pc->color($FSL7c['data']['color']); $Gm9Pc->align($FSL7c['data']['align']); $Gm9Pc->valign('top'); }); goto u9djZ; u9djZ: $x8CeK += $FSL7c['data']['size'] * 1.5; goto RO2As; RO2As: } goto Xj4iZ; rOM9A: $fNt64 = explode('[BR]', $FSL7c['data']['text']); goto WLSdM; Xj4iZ: break; goto PZ3CC; PZ3CC: case 'image': goto ZqI6X; aDoDB: $uKj64->insert($OP16_, 'top-left', $FSL7c['x'], $FSL7c['y']); goto spzAe; spzAe: break; goto ngQrZ; hKxXR: if (!empty($FSL7c['data']['opacity'])) { $OP16_->opacity($FSL7c['data']['opacity']); } goto aDoDB; LVdZG: $OP16_ = Image::make($BFUMU); goto hKxXR; ZqI6X: $BFUMU = FileUtil::savePathToLocalTemp($FSL7c['data']['image']); goto LVdZG; ngQrZ: case 'qrcode': goto W0f1j; W0f1j: $K4Hze = QrcodeUtil::png($FSL7c['data']['text'], $FSL7c['data']['width']); goto XHAfF; iHHM9: break; goto lgEtS; XHAfF: $K4Hze = Image::make($K4Hze); goto AsEu2; AsEu2: $uKj64->insert($K4Hze, 'top-left', $FSL7c['x'], $FSL7c['y']); goto iHHM9; lgEtS: } } goto hYbNI; aRgdl: $VmHM0 = FileUtil::savePathToLocalTemp($m6H3T['backgroundImage']); goto EfSav; m2x3x: $DaPqY = array(); goto z62hb; z62hb: foreach ($j5r5q as $D5qRP => $qGgGl) { $DaPqY['${' . $D5qRP . '}'] = $qGgGl; } goto VMdOG; MGWXB: $m6H3T = json_decode($m6H3T, true); goto ZbwBg; lqVKF: BizException::throwsIfEmpty('imageConfig 为空', $m6H3T); goto m2x3x; pQqJj: } }