<?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($y1urI, $KPNO0 = array()) { $O7O1_ = self::render($y1urI, $KPNO0); return 'data:image/png;base64,' . base64_encode($O7O1_); } public static function renderResponse($y1urI, $KPNO0 = array()) { $O7O1_ = self::render($y1urI, $KPNO0); return Response::raw($O7O1_, array('Content-Type' => 'image/png')); } public static function render($y1urI, $KPNO0 = array()) { goto BYW1x; Mm2g0: $O7O1_ = Image::make($FEFX4); goto oI3Tg; tMJrH: $FEFX4 = FileUtil::savePathToLocalTemp($y1urI['backgroundImage']); goto Mm2g0; YYKL5: return $O7O1_->encode('png'); goto YNGik; XetDx: $y1urI = str_replace(array_keys($LDWQO), array_values($LDWQO), $y1urI); goto juJag; juJag: $y1urI = json_decode($y1urI, true); goto KKYyA; BYW1x: BizException::throwsIfEmpty('imageConfig 为空', $y1urI); goto bfbgS; i1WVK: if (empty($y1urI['font'])) { $LGgED = FontProvider::firstLocalPathOrFail(); } else { $LGgED = FileUtil::savePathToLocalTemp($y1urI['font'], 'ttf', true); } goto tMJrH; d7NZ1: BizException::throwsIf('backgroundImage 为空', empty($y1urI['backgroundImage'])); goto oQB1k; oQB1k: BizException::throwsIf('blocks empty', !isset($y1urI['blocks'])); goto i1WVK; bfbgS: $LDWQO = array(); goto sZMIr; sZMIr: foreach ($KPNO0 as $d2HEV => $hf0nR) { $LDWQO['${' . $d2HEV . '}'] = $hf0nR; } goto HcR2I; KKYyA: BizException::throwsIf('width empty', empty($y1urI['width'])); goto Z8BGn; Z8BGn: BizException::throwsIf('height empty', empty($y1urI['height'])); goto d7NZ1; HcR2I: $y1urI = json_encode($y1urI, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); goto XetDx; oI3Tg: foreach ($y1urI['blocks'] as $zEBpl) { switch ($zEBpl['type']) { case 'text': goto ziUJe; ziUJe: $ochU_ = explode('[BR]', $zEBpl['data']['text']); goto uONOg; uONOg: $yyi7e = $zEBpl['y']; goto vPr92; vPr92: foreach ($ochU_ as $QFH5C) { goto IQbQG; IfCbg: if (empty($QFH5C)) { continue; } goto d1Gdm; d1Gdm: $O7O1_->text($QFH5C, $zEBpl['x'], $yyi7e, function ($OzZ4C) use($zEBpl, $LGgED) { $OzZ4C->file($LGgED); $OzZ4C->size($zEBpl['data']['size']); $OzZ4C->color($zEBpl['data']['color']); $OzZ4C->align($zEBpl['data']['align']); $OzZ4C->valign('top'); }); goto HG_CU; HG_CU: $yyi7e += $zEBpl['data']['size'] * 1.5; goto QFgbY; IQbQG: $QFH5C = trim($QFH5C); goto IfCbg; QFgbY: } goto SW1rl; SW1rl: break; goto Fh9rH; Fh9rH: case 'image': goto j2SZY; akF99: break; goto QBhd6; j2SZY: $htFwN = FileUtil::savePathToLocalTemp($zEBpl['data']['image']); goto bgpnW; MkEbv: if (!empty($zEBpl['data']['opacity'])) { $KC4iT->opacity($zEBpl['data']['opacity']); } goto pIy1k; pIy1k: $O7O1_->insert($KC4iT, 'top-left', $zEBpl['x'], $zEBpl['y']); goto akF99; bgpnW: $KC4iT = Image::make($htFwN); goto MkEbv; QBhd6: case 'qrcode': goto e4uDp; k4IAc: $O7O1_->insert($kVhKO, 'top-left', $zEBpl['x'], $zEBpl['y']); goto MCLfc; tkxU7: $kVhKO = Image::make($kVhKO); goto k4IAc; MCLfc: break; goto WZBMM; e4uDp: $kVhKO = QrcodeUtil::png($zEBpl['data']['text'], $zEBpl['data']['width']); goto tkxU7; WZBMM: } } goto YYKL5; YNGik: } }