Created
December 5, 2012 15:53
-
-
Save exinferis/4216799 to your computer and use it in GitHub Desktop.
Convert Data URI to JS blob - Javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dataURItoBlob = function(dataURI) { | |
var array, binary, i; | |
binary = atob(dataURI.split(",")[1]); | |
array = []; | |
i = 0; | |
while (i < binary.length) { | |
array.push(binary.charCodeAt(i)); | |
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
Very nice work!
And I'd like to add some snippet here.