Skip to content

Instantly share code, notes, and snippets.

@djdarcy
Created November 2, 2025 21:47
Show Gist options
  • Select an option

  • Save djdarcy/5796b7b2d705278aa4ad612248fd7c77 to your computer and use it in GitHub Desktop.

Select an option

Save djdarcy/5796b7b2d705278aa4ad612248fd7c77 to your computer and use it in GitHub Desktop.
Fit Mask to Image for ComfyUI
{
"id": "063eb380-3f11-4582-9fdc-c4ab01fb5ecb",
"revision": 0,
"last_node_id": 1098,
"last_link_id": 2788,
"nodes": [
{
"id": 1060,
"type": "Reroute (rgthree)",
"pos": [
1688.548095703125,
-2528.18505859375
],
"size": [
40,
30
],
"flags": {},
"order": 0,
"mode": 0,
"inputs": [
{
"dir": 3,
"label": " ",
"name": "",
"type": "*",
"link": null
}
],
"outputs": [
{
"dir": 4,
"label": " ",
"name": "",
"type": "*",
"slot_index": 0,
"links": [
2298,
2299,
2300,
2305
]
}
],
"properties": {
"resizable": false,
"size": [
40,
30
],
"ue_properties": {
"widget_ue_connectable": {},
"version": "7.1",
"input_ue_unconnectable": {}
}
},
"color": "#223",
"bgcolor": "#335"
},
{
"id": 1064,
"type": "MergeImageChannels",
"pos": [
2086.52685546875,
-2323.509765625
],
"size": [
252,
86
],
"flags": {},
"order": 7,
"mode": 0,
"inputs": [
{
"name": "red",
"type": "IMAGE",
"link": 2298
},
{
"name": "green",
"type": "IMAGE",
"link": 2299
},
{
"name": "blue",
"type": "IMAGE",
"link": 2300
},
{
"name": "alpha",
"shape": 7,
"type": "MASK",
"link": 2301
}
],
"outputs": [
{
"name": "image",
"type": "IMAGE",
"slot_index": 0,
"links": [
2302,
2309
]
}
],
"title": "Merge Mask/Alpha w Orig Img",
"properties": {
"cnr_id": "comfyui-kjnodes",
"ver": "a5bd3c86c8ed6b83c55c2d0e7a59515b15a0137f",
"Node name for S&R": "MergeImageChannels",
"ue_properties": {
"widget_ue_connectable": {},
"version": "7.1",
"input_ue_unconnectable": {}
}
},
"widgets_values": []
},
{
"id": 1063,
"type": "Reroute (rgthree)",
"pos": [
1688.11767578125,
-2478.57568359375
],
"size": [
40,
30
],
"flags": {},
"order": 1,
"mode": 0,
"inputs": [
{
"dir": 3,
"label": " ",
"name": "",
"type": "*",
"link": null
}
],
"outputs": [
{
"dir": 4,
"label": " ",
"name": "",
"type": "*",
"slot_index": 0,
"links": [
2297
]
}
],
"properties": {
"resizable": false,
"size": [
40,
30
],
"ue_properties": {
"widget_ue_connectable": {},
"version": "7.1",
"input_ue_unconnectable": {}
}
},
"color": "#232",
"bgcolor": "#353"
},
{
"id": 1068,
"type": "ImpactImageInfo",
"pos": [
1764.3907470703125,
-2478.92626953125
],
"size": [
144.175390625,
86
],
"flags": {},
"order": 2,
"mode": 0,
"inputs": [
{
"name": "value",
"type": "IMAGE",
"link": 2305
}
],
"outputs": [
{
"name": "batch",
"type": "INT",
"links": null
},
{
"name": "height",
"type": "INT",
"slot_index": 1,
"links": [
2296
]
},
{
"name": "width",
"type": "INT",
"slot_index": 2,
"links": [
2295
]
},
{
"name": "channel",
"type": "INT",
"links": null
}
],
"properties": {
"cnr_id": "comfyui-impact-pack",
"ver": "8.8.1",
"Node name for S&R": "ImpactImageInfo",
"ue_properties": {
"widget_ue_connectable": {},
"version": "7.1",
"input_ue_unconnectable": {}
}
},
"widgets_values": []
},
{
"id": 1062,
"type": "MaskToImage",
"pos": [
1921.3797607421875,
-2491.40673828125
],
"size": [
184.6236328125,
26
],
"flags": {},
"order": 3,
"mode": 0,
"inputs": [
{
"name": "mask",
"type": "MASK",
"link": 2297
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"slot_index": 0,
"links": [
2294
]
}
],
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.27",
"Node name for S&R": "MaskToImage",
"ue_properties": {
"widget_ue_connectable": {},
"version": "7.1",
"input_ue_unconnectable": {}
}
},
"widgets_values": []
},
{
"id": 1061,
"type": "ImageScale",
"pos": [
2132.0263671875,
-2499.9296875
],
"size": [
210,
170
],
"flags": {
"collapsed": false
},
"order": 4,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 2294
},
{
"name": "width",
"type": "INT",
"widget": {
"name": "width"
},
"link": 2295
},
{
"name": "height",
"type": "INT",
"widget": {
"name": "height"
},
"link": 2296
}
],
"outputs": [
{
"name": "IMAGE",
"type": "IMAGE",
"slot_index": 0,
"links": [
2303,
2304
]
}
],
"title": "Upscale Mask",
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.27",
"Node name for S&R": "ImageScale",
"ue_properties": {
"widget_ue_connectable": {
"width": true,
"height": true
},
"version": "7.1",
"input_ue_unconnectable": {}
}
},
"widgets_values": [
"nearest-exact",
0,
1920,
"disabled"
]
},
{
"id": 1067,
"type": "ImageToMask",
"pos": [
1823.665771484375,
-2329.017578125
],
"size": [
210,
58
],
"flags": {},
"order": 6,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 2304
}
],
"outputs": [
{
"name": "MASK",
"type": "MASK",
"slot_index": 0,
"links": [
2301
]
}
],
"title": "Convert Mask to Alpha",
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.27",
"Node name for S&R": "ImageToMask",
"ue_properties": {
"widget_ue_connectable": {},
"version": "7.1",
"input_ue_unconnectable": {}
}
},
"widgets_values": [
"red"
]
},
{
"id": 1065,
"type": "PreviewImage",
"pos": [
2152.784423828125,
-2168.951416015625
],
"size": [
243.97653198242188,
294.846923828125
],
"flags": {
"collapsed": true
},
"order": 8,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 2302
}
],
"outputs": [],
"title": "Preview Img w Alpha",
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.27",
"Node name for S&R": "PreviewImage",
"ue_properties": {
"widget_ue_connectable": {},
"version": "7.1",
"input_ue_unconnectable": {}
}
},
"widgets_values": []
},
{
"id": 1066,
"type": "PreviewImage",
"pos": [
1947.45068359375,
-2166.244140625
],
"size": [
250.4730224609375,
312.6358947753906
],
"flags": {
"collapsed": true
},
"order": 5,
"mode": 0,
"inputs": [
{
"name": "images",
"type": "IMAGE",
"link": 2303
}
],
"outputs": [],
"title": "Preview upscaled mask",
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.27",
"Node name for S&R": "PreviewImage",
"ue_properties": {
"widget_ue_connectable": {},
"version": "7.1",
"input_ue_unconnectable": {}
}
},
"widgets_values": []
},
{
"id": 1069,
"type": "ImageToMask",
"pos": [
2380.558349609375,
-2259.1884765625
],
"size": [
210,
58
],
"flags": {
"collapsed": false
},
"order": 9,
"mode": 0,
"inputs": [
{
"name": "image",
"type": "IMAGE",
"link": 2309
}
],
"outputs": [
{
"name": "MASK",
"type": "MASK",
"slot_index": 0,
"links": []
}
],
"title": "Img-Mask",
"properties": {
"cnr_id": "comfy-core",
"ver": "0.3.27",
"Node name for S&R": "ImageToMask",
"ue_properties": {
"widget_ue_connectable": {},
"version": "7.1",
"input_ue_unconnectable": {}
}
},
"widgets_values": [
"alpha"
]
}
],
"links": [
[
2294,
1062,
0,
1061,
0,
"IMAGE"
],
[
2295,
1068,
2,
1061,
1,
"INT"
],
[
2296,
1068,
1,
1061,
2,
"INT"
],
[
2297,
1063,
0,
1062,
0,
"MASK"
],
[
2298,
1060,
0,
1064,
0,
"IMAGE"
],
[
2299,
1060,
0,
1064,
1,
"IMAGE"
],
[
2300,
1060,
0,
1064,
2,
"IMAGE"
],
[
2301,
1067,
0,
1064,
3,
"MASK"
],
[
2302,
1064,
0,
1065,
0,
"IMAGE"
],
[
2303,
1061,
0,
1066,
0,
"IMAGE"
],
[
2304,
1061,
0,
1067,
0,
"IMAGE"
],
[
2305,
1060,
0,
1068,
0,
"IMAGE"
],
[
2309,
1064,
0,
1069,
0,
"IMAGE"
]
],
"groups": [
{
"id": 57,
"title": "Ph6 & 2 - 1. Fix Mask",
"bounding": [
1665.90283203125,
-2576.8740234375,
695,
449
],
"color": "#3f789e",
"font_size": 24,
"flags": {}
}
],
"config": {},
"extra": {
"ds": {
"scale": 0.8140274938683995,
"offset": [
-1244.3022805685519,
2932.515520708891
]
},
"ue_links": [],
"node_versions": {
"comfy-core": "0.3.23",
"ComfyUI-Impact-Pack": "c6056b132d7e155c3ece42b77e08ea45bde1bfef",
"ComfyUI-KJNodes": "095c8d4b526ba3c1f12fd9dd1d7f3540c6a11358",
"was-node-suite-comfyui": "056badacda52e88d29d6a65f9509cd3115ace0f2",
"ComfyUI_ADV_CLIP_emb": "63984deefb005da1ba90a1175e21d91040da38ab",
"comfyui-art-venture": "50abaace756b96f5f5dc2c9d72826ef371afd45e",
"rgthree-comfy": "31b784bac495160436a8cd91bf1a856cf01a738e",
"ComfyUI-Inspire-Pack": "ecf8ab6f588bc8442ff7720b383d085ecabbc407",
"comfyui_pulid_flux_ll": "5f1e91d1d66884dd2b43a6e3e8e0c8a78638fa35",
"cg-image-picker": "f349bc0a38ab78a1289e808ec824f3be553594c3",
"ComfyUI_IPAdapter_plus": "e5c9744b232ac812b5430fbdc4ebe9f7789bd8d2",
"comfyui_segment_anything": "ab6395596399d5048639cdab7e44ec9fae857a93",
"ComfyUI---Unload-Models": "bf0ffda636e4f51ca99e66ea0d39a0eb5152bd26",
"ComfyUI-Impact-Subpack": "74db20c95eca152a6d686c914edc0ef4e4762cb8",
"ComfyUI_UltimateSDUpscale": "ff3fdfeee03de46d4462211cffd165d27155e858",
"ComfyUI-Custom-Scripts": "bbda5e52ad580c13ceaa53136d9c2bed9137bd2e",
"x-flux-comfyui": "00328556efc9472410d903639dc9e68a8471f7ac",
"ComfyUI-Advanced-ControlNet": "b66cd70c9845a109a85b4a0ef13cefda41ca6039",
"ControlAltAI-Nodes": "404b22d09283b2ece48da6c4e024d4d6beaecb07",
"ComfyUI-GGUF": "5875c52f59baca3a9372d68c43a3775e21846fe0",
"ComfyUI_Comfyroll_CustomNodes": "d78b780ae43fcf8c6b7c6505e6ffb4584281ceca",
"ComfyUI-TiledDiffusion": "448e961d8289779eeef9045c1cf7ef438e3a2a7b",
"ComfyUI_tinyterraNodes": "251f805aede3fbcb31009233f65170e603d45406",
"sd-dynamic-thresholding": "5d63447afbc44b377f706a5eb0430f85791dcf30",
"ComfyUI-AutomaticCFG": "2e395317b65c05a97a0ef566c4a8c7969305dafa",
"comfy-plasma": "c63555fec40a7dddb36c99aa603e817abab3abdb",
"ComfyUI_essentials": "33ff89fd354d8ec3ab6affb605a79a931b445d99",
"ComfyUI-SUPIR": "53fc4f82f139e0875e1f4f3716fbeafa073e4242",
"comfyui-easy-use": "52a8e7faf37753b840e863dd4a6b245ddaf87761",
"comfyui_controlnet_aux": "1e9eac6377c882da8bb360c7544607036904362c",
"efficiency-nodes-comfyui": "3ead4afd120833f3bffdefeca0d6545df8051798"
},
"VHS_latentpreview": false,
"VHS_latentpreviewrate": 0,
"VHS_MetadataImage": true,
"VHS_KeepIntermediate": true,
"frontendVersion": "1.28.8",
"links_added_by_ue": []
},
"version": 0.4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment