将Base64的字符串转换为二进制数,代码如下:
function dataURItoBlob(dataURI) {
// convert base64 to raw binary data held in a string
// doesn't handle URLEncoded DataURIs - see SO answer #6850276 for code that does this
var byteString = atob(dataURI.split(',')[1]);
// separate out the mime component
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]
// write the bytes of the string to an ArrayBuffer
var ab = new ArrayBuffer(byteString.length);
// create a view into the buffer
var ia = new Uint8Array(ab);
// set the bytes of the buffer to the correct values
for (var i = 0; i < byteString.length; i++) {
ia[i] = byteString.charCodeAt(i);
}
// write the ArrayBuffer to a blob, and you're done
var blob = new Blob([ab], {type: mimeString});
return blob;
}
// 将Base64的字符串转换为二进制数据
var blob = dataURItoBlob(image);
// 使用FileSaver.js的saveAs函数进行下载
saveAs(blob, "images.png"); 网友回复
如何在cli命令行中渲染浏览网页?
未来的工作会不会变成如何使用很少的tokens词元来高效完成任务?
openclaw如何更换端口号外网http直接访问?
openclaw能否在无桌面ui的linux系统运行?
什么是Harness Engineering?
同一个中英混合文本不同大模型计算tokens长度一致吗?
Browser Use / Playwright / Puppeteer 与Chrome DevTools Protocol(CDP)的关系?
能否在三维空间调用ai的api实现vrm模型执行任意的姿势动作与行走完成任务?
如何让openclaw小龙虾自动帮你打电话聊客户?
各大公司推出的claw是否是为了大家消费自己的大模型tokens?


