Currently, I am working with the FabricJS canvas and my goal is to export the canvas as JSON.
I have experimented with loading images using both new fabric.Image
and fabric.Image.fromURL
, and both methods have worked well for me.
My next task is to obtain JSON data from the canvas. However, I require two different types of JSON outputs. One should include a link to the image used initially, while the other should directly embed base64 data within the JSON itself. I have attempted to use canvas.toJSON()
and canvas.toDatalessJSON()
, but surprisingly, they both only provide results with a link and do not contain any image data.
How can I generate JSON output that actually INCLUDES image data directly in the JSON? (I already have it with the link)
I have created a simple demo showcasing my current progress. Upon clicking on the export button and checking the console, you will notice that both objects display the source link without any base64 data included.
The reason I am interested in base64 data is because I want immediate access when reusing the JSON elsewhere.
Despite searching online and consulting the documentation, it appears that toJSON function only captures shape data and not image information. Have I overlooked something crucial?
Thank you in advance!