From 5b523ce4f4655bde5a4417ac656fc4fd116e547b Mon Sep 17 00:00:00 2001 From: Jedrzej Kosinski Date: Mon, 5 May 2025 23:37:21 -0500 Subject: [PATCH] Invert and resize mask for Ideogram V3 node to match masking conventions (#158) --- comfy_api_nodes/nodes_ideogram.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/comfy_api_nodes/nodes_ideogram.py b/comfy_api_nodes/nodes_ideogram.py index 3f80a62d7..45c021f4a 100644 --- a/comfy_api_nodes/nodes_ideogram.py +++ b/comfy_api_nodes/nodes_ideogram.py @@ -21,6 +21,7 @@ from comfy_api_nodes.apis.client import ( from comfy_api_nodes.apinode_utils import ( download_url_to_bytesio, bytesio_to_image_tensor, + resize_mask_to_image, ) V1_V1_RES_MAP = { @@ -649,6 +650,10 @@ class IdeogramV3(ComfyNodeABC): # Process image and mask input_tensor = image.squeeze().cpu() + # Resize mask to match image dimension + mask = resize_mask_to_image(mask, image, allow_gradient=False) + # Invert mask, as Ideogram API will edit black areas instead of white areas (opposite of convention). + mask = 1.0 - mask # Validate mask dimensions match image if mask.shape[1:] != image.shape[1:-1]: