0
我正在使用Mapbox's Javascript PBF library將PBF
文件轉換爲png
。對於上下文,這裏是我到目前爲止有:將base64圖像數據轉換爲png?
var pbfFile = new pbf(fs.readFileSync('0.pbf')), // pbfFile.buf gives us the binary data for the image
buffer = new Uint8Array();
buffer = pbfFile.readBytes();
console.log("Raw Uint8 data: " + buffer);
var bufferToBase64 =btoa(String.fromCharCode.apply(null, buffer));
console.log("Image data in base64: " + bufferToBase64);
其輸出以下:
Raw Uint8 data: 139,8,0,0,0,0,0,0,3,157,86,123,84,84,199,25,223,111,230,238,222,185,23,88,150,187,168,184,32,44,23
Image data in base64: iwgAAAAAAAADnVZ7VFTHGd9v5u7euRdYlruouCAsFw==
我有點失去了,我怎麼能以base64數據轉換爲png
圖像和通它到我的服務器。我有一臺express
服務器運行並收聽請求,現在上面的代碼在我通過終端連接到它時運行。
有沒有一種方法可以將上述base 64轉換並將圖像發送到我的瀏覽器?不一定在畫布上,就像一個文件(從而提示下載)一樣完美。