html5 - Download image with Javascript and convert it to a Blob -
with html5 , filereader/blob can convert from/to blobs/datauris, i'm wondering if can download image remote url , convert blob (or datauri).
if possible, how it?
i managed myself:
var xhr = new xmlhttprequest(); xhr.open('get', attr.ngfdefaultsrc, true); xhr.responsetype = 'blob'; xhr.onload = function(e) { if (this.status !== 200) return; var blob = new blob([this.response], {type: this.response.type}); //rest of code uses blob goes here }; xhr.send();
Comments
Post a Comment