Skip to content

Instantly share code, notes, and snippets.

@marcelaraujo
Created May 2, 2017 16:43
Show Gist options
  • Select an option

  • Save marcelaraujo/79f3001df2e92f3f63a4df29097b3171 to your computer and use it in GitHub Desktop.

Select an option

Save marcelaraujo/79f3001df2e92f3f63a4df29097b3171 to your computer and use it in GitHub Desktop.
Image 1x1 blob
// 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 binary = fixBinary(atob("iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAAAAAA6fptVAAAACklEQVR4nGP6DwABBQECz6AuzQAAAABJRU5ErkJggg=="));
var image = new Blob([binary], {type: 'image/png'});
image.name = 'pixel.png';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment