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

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -