简体   繁体   English

如何在 TOAST UI 组件图像编辑器中访问画布?

[英]How to get access to canvas in the TOAST UI Component Image Editor?

I use TOAST UI Component Image Editor on a webpage.我在网页上使用TOAST UI 组件图像编辑器 I'd like to to save the image to Base64 string.我想将图像保存为 Base64 字符串。 There are no properties in imageEditor object to allow me to access the edited image in canvas. imageEditor 对象中没有允许我访问画布中编辑过的图像的属性。 I searched Google and Stackoverflow, no results.我搜索了谷歌和 Stackoverflow,没有结果。

I checked the file tui-image-editor.js for download function as suggested by gaetanoM.我按照 gaetanoM 的建议检查了文件tui-image-editor.js的下载功能。

The solution is to call for base64 string of the edited image.解决方案是调用已编辑图像的 base64 字符串。 The base64 string starts after the data:image/png;base64, prefix. base64 字符串在data:image/png;base64,前缀之后开始。

imageEditor.toDataURL();

Where imageEditor is a global JavaScript variable declared during image load.其中imageEditor是在图像加载期间声明的全局 JavaScript 变量。

It is using fabric.js library.它使用的是fabric.js 库。 You can access the canvas object directly by :您可以通过以下方式直接访问画布对象:

ImageEditor._graphics.getCanvas(); ImageEditor._graphics.getCanvas();

it will give you a fabric object, assign this to some variable and you can use fabric.js functions with this.它会给你一个fabric对象,将它分配给某个变量,你可以使用fabric.js函数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM