2

I use TOAST UI Component Image Editor on a webpage. I'd like to to save the image to Base64 string. There are no properties in imageEditor object to allow me to access the edited image in canvas. I searched Google and Stackoverflow, no results.

yW0K5o
  • 913
  • 1
  • 17
  • 32
  • 1
    try to take a look [to this answer](https://stackoverflow.com/questions/15685698/getting-binary-base64-data-from-html5-canvas-readasbinarystring) In any case I assume there should be a download method – gaetanoM Aug 11 '18 at 21:46
  • @gaetanoM, Thank you for your response. I take a look at download method. – yW0K5o Aug 11 '18 at 22:05

2 Answers2

4

I checked the file tui-image-editor.js for download function as suggested by gaetanoM.

The solution is to call for base64 string of the edited image. The base64 string starts after the data:image/png;base64, prefix.

imageEditor.toDataURL();

Where imageEditor is a global JavaScript variable declared during image load.

yW0K5o
  • 913
  • 1
  • 17
  • 32
1

It is using fabric.js library. You can access the canvas object directly by :

ImageEditor._graphics.getCanvas();

it will give you a fabric object, assign this to some variable and you can use fabric.js functions with this.

Amandeep Singh
  • 156
  • 1
  • 8