mercredi 1 juillet 2015

How to download an image object from webgl/javascript

I have a directory with 100 images. I need a copy of them in various folders along with other information that I download from webgl. Hence I want to upload them onto the browser and download them again (hope that isn't stupid)

Here is my code:

var imagefile = model.features[cIndex].imageName.substring(model.features[cIndex].imageName.lastIndexOf('/')+1);
var image = new Image();
image.src = model.imageDirectory + imagefile;
image.onload = function() {
console.info("Read \""+image.src + "\"...Done");
}
image.onerror = function() {
var message = "Unable to open \"" + image.src + "\".";
console.error(message);
alert(message);
}

var data = image.src;

zip.file('image_RH_Original' + cIndex +'.png', data , {base64: true}); 

Is this wrong? How to I do something similar to "toDataURL" for the image object?

Aucun commentaire:

Enregistrer un commentaire