public function getBaseByUrl($url){ $img_base64 = ''; if($fgc = @file_get_contents($url)){ $b64 = base64_encode($fgc); $info = getimagesize($url); switch ($info[2]) { //判读图片类型 case 1: $img_type = "gif"; break; case 2: $img_type = "jpeg"; break; case 3: $img_type = "png"; break; } $img_base64 = 'data:image/' . $img_type . ';base64,' . $b64;//合成图片的base64编码 } return $img_base64; }
根据远程地址转化图片ba64
于 2021-09-10 14:41:00 首次发布