Mask canvas for masked img2img

This commit is contained in:
space-nuko
2023-05-27 20:37:22 -05:00
parent 7e2b6111dd
commit cb9e8540a0
9 changed files with 5415 additions and 235 deletions

View File

@@ -8,12 +8,14 @@ import ComfyWidgetNode from "./ComfyWidgetNode";
import { get, writable, type Writable } from "svelte/store";
export interface ComfyImageUploadNodeProperties extends ComfyWidgetProperties {
maskCount: number
}
export default class ComfyImageUploadNode extends ComfyWidgetNode<ComfyBoxImageMetadata[]> {
properties: ComfyImageUploadNodeProperties = {
defaultValue: [],
tags: [],
maskCount: 0
}
static slotLayout: SlotLayout = {
@@ -39,13 +41,21 @@ export default class ComfyImageUploadNode extends ComfyWidgetNode<ComfyBoxImageM
super(name, [])
}
override onExecute() {
override onExecute(param: any, options: object) {
// TODO better way of getting image size?
const value = get(this.value)
if (value && value.length > 0) {
value[0].width = get(this.imgWidth)
value[0].height = get(this.imgHeight)
// NOTE: assumes masks will have the same image size as the parent image!
for (const child of value[0].children) {
child.width = get(this.imgWidth)
child.height = get(this.imgHeight)
}
}
super.onExecute(param, options);
}
override parseValue(value: any): ComfyBoxImageMetadata[] {