php – imagecreatefromstring使用带有数据的图像:image / png;
发布时间:2020-12-13 17:23:16 所属栏目:PHP教程 来源:网络整理
导读:我有一个存储为字符串的图像,它以: data:image/png;base64, 我需要将它转换为普通图像,以便与GD一起使用. 我试过imagecreatefromstring()但它似乎只接受没有数据的图像:image / etc pefix. 我能怎么做? 解决方法 $exploded = explode(',',$data,2); // li
我有一个存储为字符串的图像,它以:
data:image/png;base64, 我需要将它转换为普通图像,以便与GD一起使用. 我试过imagecreatefromstring()但它似乎只接受没有数据的图像:image / etc pefix. 我能怎么做? 解决方法$exploded = explode(',',$data,2); // limit to 2 parts,i.e: find the first comma $encoded = $exploded[1]; // pick up the 2nd part $decoded = base64_decode($encoded); $img_handler = imagecreatefromstring($decoded); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |