Covert Base64 image to blob and back to Base64
HTML
<h1>Create an image/png blob, then fetch it with XHR</h1>
<a href="https://bl.ocks.org/nolanlawson/0eac306e4dac2114c752">Source</a>
<pre id="display"></pre>
<script src="index.js"></script>
JavaScript
(function () {
'use strict';
// From http://stackoverflow.com/questions/14967647/ (continues on next line)
// encode-decode-image-with-base64-breaks-image (2013-04-21)
function fixBinary (bin) {
var length = bin.length;
var buf = new ArrayBuffer(length);
var arr = new Uint8Array(buf);
for (var i = 0; i < length; i++) {
arr[i] = bin.charCodeAt(i);
}
return buf;
}
var display = document.getElementById('display');
display.innerHTML = (display.innerHTML || '');
function log(text) {
display.innerHTML += "\n" + text;
}
var base64 =
...