Exclude element from canvas to be saved to json (fabric.js)

Viewed 2239

I am using

 var jsonToPHP= JSON.stringify(canvas.toObject(['id','name']));

to save all from canvas to JSON.

I am also adding background image to canvas.

document.getElementById('imgLoader').addEventListener("change", function (e) {   var file = e.target.files[0];   var reader = new FileReader();   reader.onload = function (f) {
    var data = f.target.result;                    
    fabric.Image.fromURL(data, function (img) {
    var oImg = img.set({left: 0, top: 0, angle: 00,width:canvas.width, height:canvas.height,}).scale(1);
    oImg.set('selectable', false);
    canvas.add(oImg).renderAll();
    var dataURL = canvas.toDataURL({format: 'png', quality: 0.8});
    });   };   reader.readAsDataURL(file);

});

But i would like to exclude background image to be saved to JASON.

I vas googling for:

Exclude element from canvas to be saved to json fabric.js

and i have got next:

in the fabricjs docs there is a property for the Object class calles 'excludeFromExport'.

Once set to true it should do exactly what you want.

www.fabricjs.com/docs

I went to:

Source: fabric.js, line 12350 excludeFromExport

And what now?

My knowlage is to less to get to result from this. Does any one can give more informations: maybe one example?

Thank you

1 Answers
Related