nhn / toast-ui.vue-image-editor

Toast UI Image Editor for Vue

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

如何通过另外的方法(不通过自带的DOWNLOAD) 获取到编辑后的图像

tonytu0510 opened this issue · comments

hello world~~~
我想保存编辑后的图片到数据库 请问有什么办法可以做到吗 谢谢

saveImg(){
let lowerCas=this.$refs.tuiImageEditor.getRootElement().getElementsByClassName("lower-canvas")[0]
let upperCas=this.$refs.tuiImageEditor.getRootElement().getElementsByClassName("upper-canvas ")[0]
const canvasSize = this.$refs.tuiImageEditor.invoke('getCanvasSize')
let width=canvasSize.width
let height=canvasSize.height
lowerCas.getContext("2d").drawImage(upperCas,0,0,width,height);
// 把画布的内容转换为base64编码格式的图片
let data = lowerCas.toDataURL( 'image/png', 1 ); //1表示质量(无损压缩)
console.log(data)
}

For further reference, I achieved it this way:

  • Add a reference to your vue element:
    <tui-image-editor ref="tuiEditor" />

  • On your save method:

save() {
  const image = this.$refs.tuiEditor.editorInstance.toDataURL();
  console.log(image);
}

Link to the documentation