get($url); $fp = @fopen($fullFileName, 'a'); fwrite($fp, $result); fclose($fp); $imgInfo = getimagesize($fullFileName); if (empty($imgInfo) || isset($imgInfo[0]) == false) { return ''; } $width = $imgInfo[0]; $height = $imgInfo[1]; //生成小图 280px $smallWidth = 280; $smallHeight = ceil((280 * $height) / $width); if ($width <= 280) { $smallWidth = $width; $smallHeight = $height; } $smallFullPathFile = $path . $middle . $sjId . '_small.jpg'; Image::thumbnail($fullFileName, $smallWidth, $smallHeight)->save($smallFullPathFile, ['quality' => 100]); return $fileName; } //保存公众号二维码 ssh 2020.3.11 public static function saveQrCode($url, $sjId) { $path = dirUtil::getImgDir(); $middle = "wx/merchant/qrCode/"; if (!file_exists($path . $middle)) { mkdir($path . $middle, 0777, true); } if (empty($sjId)) { $sjId = stringUtil::shortUniqueId($sjId); } $name = $sjId . '.jpg'; $fullFileName = $path . $middle . $name; $fileName = $middle . $name; if (file_exists($fullFileName)) { return $fileName; } $curl = new curl\Curl(); $result = $curl->get($url); $fp = @fopen($fullFileName, 'a'); fwrite($fp, $result); fclose($fp); $imgInfo = getimagesize($fullFileName); if (empty($imgInfo) || isset($imgInfo[0]) == false) { return ''; } $width = $imgInfo[0]; $height = $imgInfo[1]; //生成小图 280px $smallWidth = 280; $smallHeight = ceil((280 * $height) / $width); if ($width <= 280) { $smallWidth = $width; $smallHeight = $height; } $smallFullPathFile = $path . $middle . $sjId . '_small.jpg'; Image::thumbnail($fullFileName, $smallWidth, $smallHeight)->save($smallFullPathFile, ['quality' => 100]); return $fileName; } //取公众号信息 0表示平台的公众号 ssh 2020.4.26 public static function getWxBase($id = 0) { return self::getByCondition(['sjId' => 0]); } }