{"log_id":5902809968303570582,"error_code":216201,"error_msg":"image format error"}
调用的PHP SDK,部分代码,求大神帮忙解答一下
public function submit(Request $request){
$images = 'http://123.56.180.244/dream/public/images/gif/20190722/e1832529921890d051b7ec5e5eefe1a5.png';
$images = $this->base64EncodeImage($images);echo '';
$images = substr($images,22);
$images = urlencode($images);
$client = new AipImageClassify($this->app_id,$this->api_key,$this->secret_key);
$res = $client->advancedGeneral($images);
return json_encode($res);
}
function base64EncodeImage ($image_file) {
$image_info = getimagesize($image_file);
$image_data = fread(fopen($image_file, 'r'), filesize($image_info['mime']));
$base64_image = 'data:' . $image_info['mime'] . ';base64,' . chunk_split(base64_encode($image_data));
return $base64_image;
}
问题已经解决了 只需要用file_get_contents去那线上文件然后请求SDK就可以了... 不需要转换base64编码