MCPcopy Index your code
hub / github.com/easydiffusion/easydiffusion / saveImage

Method saveImage

ui/media/js/image-editor.js:624–639  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

622 this.history.clear()
623 }
624 saveImage() {
625 if (!this.inpainter) {
626 // This is not an inpainter, so save the image as the new img2img input
627 this.layers.background.ctx.drawImage(this.layers.drawing.canvas, 0, 0, this.width, this.height)
628 var base64 = this.layers.background.canvas.toDataURL()
629 initImagePreview.src = base64 // this will trigger the rest of the app to use it
630 } else {
631 // This is an inpainter, so make sure the toggle is set accordingly
632 var is_blank = !this.layers.drawing.ctx
633 .getImageData(0, 0, this.width, this.height)
634 .data.some((channel) => channel !== 0)
635 maskSetting.checked = !is_blank
636 maskSetting.dispatchEvent(new Event("change"))
637 }
638 this.hide()
639 }
640 getImg() {
641 // a drop-in replacement of the drawingboard version
642 return this.layers.drawing.canvas.toDataURL()

Callers 2

setSizeMethod · 0.95
image-editor.jsFile · 0.80

Calls 2

hideMethod · 0.95
dispatchEventMethod · 0.45

Tested by

no test coverage detected