nhn / toast-ui.vue-image-editor

Toast UI Image Editor for Vue
MIT License
187 stars 41 forks source link

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

Closed tonytu0510 closed 5 years ago

tonytu0510 commented 5 years ago

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

tonytu0510 commented 5 years ago

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) }

rodrigomata commented 5 years ago

For further reference, I achieved it this way:

Link to the documentation

tonytu0510 commented 5 years ago

en en thanks

在 2019-03-27 01:07:06,"Rodrigo Mata" notifications@github.com 写道:

For further reference, I achieved it this way:

Add a reference to your vue element:

On your save method:

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

Link to the documentation

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub, or mute the thread.