Skip to content

Instantly share code, notes, and snippets.

@apendua
Forked from taberh/README.md
Created July 29, 2014 17:08
Show Gist options
  • Save apendua/5a121585a9d4e4c84e14 to your computer and use it in GitHub Desktop.
Save apendua/5a121585a9d4e4c84e14 to your computer and use it in GitHub Desktop.

#Covert Data URI to Blob

/**
* Convert Data URI to Blob
*/
function dataURItoBlob(dataURI) {
var binary = atob(dataURI.split(',')[1]);
var array = [];
var i = 0;
var l = binary.length;
for ( ; i < l; i++) {
array.push(binary.charCodeAt(i));
}
return new Blob([new Uint8Array(array)], {type: 'image/jpeg'});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment