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

Method setImage

ui/media/js/image-editor.js:604–623  ·  view source on GitHub ↗
(url, width, height)

Source from the content-addressed store, hash-verified

602 this.container.style.cursor = this.tool.cursor
603 }
604 setImage(url, width, height) {
605 this.setSize(width, height)
606 this.layers.background.ctx.clearRect(0, 0, this.width, this.height)
607 if (!(url && this.inpainter)) {
608 this.layers.drawing.ctx.clearRect(0, 0, this.width, this.height)
609 }
610 if (url) {
611 var image = new Image()
612 image.onload = () => {
613 this.layers.background.ctx.drawImage(image, 0, 0, this.width, this.height)
614 }
615 image.src = url
616 } else {
617 this.layers.background.ctx.fillStyle = "#ffffff"
618 this.layers.background.ctx.beginPath()
619 this.layers.background.ctx.rect(0, 0, this.width, this.height)
620 this.layers.background.ctx.fill()
621 }
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

Callers 5

image-editor.jsFile · 0.80
onUseAsThumbnailClickFunction · 0.80
onDimensionChangeFunction · 0.80
img2imgLoadFunction · 0.80
img2imgUnloadFunction · 0.80

Calls 2

setSizeMethod · 0.95
clearMethod · 0.45

Tested by

no test coverage detected