我目前正在执行以下操作来解码
PHP中的base64图像:
$img = str_replace('data:image/jpeg;base64,','',$s['image']); $img = str_replace('data:image/png;base64,$s['image']); $img = str_replace('data:image/gif;base64,$s['image']); $img = str_replace('data:image/bmp;base64,$s['image']); $img = str_replace(' ','+',$img); $data = base64_decode($img);
如您所见,我们接受四种最标准的图像类型(jpeg,png,gif,bmp);@H_502_4@
然而,这些图像中的一些非常大,并且使用str_replace扫描每个图像4-5次似乎是一种可怕的浪费并且非常低效.@H_502_4@
有没有办法可以可靠地剥离数据:一次传递中base64图像字符串的图像部分?也许通过检测字符串中的第一个逗号?@H_502_4@