Skip to content

Commit 417e6eb

Browse files
Copilotdunkeroni
authored andcommitted
Simplify mask application by pasting base on corrected instead of inverting mask
Co-authored-by: dunkeroni <[email protected]>
1 parent 7919d65 commit 417e6eb

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

invokeai/app/invocations/image.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -733,12 +733,9 @@ def invoke(self, context: InvocationContext) -> ImageOutput:
733733
if self.mask is not None:
734734
# Load mask as grayscale
735735
mask_image = context.images.get_pil(self.mask.image_name, "L")
736-
# Invert mask: Image.paste uses white to paste, but we want white=original, black=result
737-
# So we paste the corrected image where mask is black (inverted)
738-
inverted_mask = ImageOps.invert(mask_image)
739-
# Start with base image, paste corrected where mask is black (now white in inverted)
740-
result = base_image.convert("RGB").copy()
741-
result.paste(corrected_image, mask=inverted_mask)
736+
# Start with corrected image, paste base image where mask is white
737+
result = corrected_image.copy()
738+
result.paste(base_image.convert("RGB"), mask=mask_image)
742739
else:
743740
result = corrected_image
744741

0 commit comments

Comments
 (0)