This commit is contained in:
Yousef Rafat 2026-04-29 14:32:48 +03:00
parent cde0936e42
commit 8e3396c035
2 changed files with 23 additions and 11 deletions

View File

@ -42,8 +42,8 @@ class ConvertColorSpace(IO.ComfyNode):
category="image/color", category="image/color",
inputs=[ inputs=[
IO.Image.Input("images"), IO.Image.Input("images"),
IO.Combo.Input("source_color_space", options=["sRGB", "Linear", "HDR (Rec.2020)", "Grayscale"], default="sRGB"), IO.Combo.Input("source_color_space", options=["sRGB", "Linear", "HDR Display (PQ/Rec.2020)", "Grayscale"], default="sRGB"),
IO.Combo.Input("target_color_space", options=["sRGB", "Linear", "HDR (Rec.2020)", "Grayscale"], default="Linear"), IO.Combo.Input("target_color_space", options=["sRGB", "Linear", "HDR Display (PQ/Rec.2020)", "Grayscale"], default="Linear"),
], ],
outputs=[ outputs=[
IO.Image.Output("images"), IO.Image.Output("images"),
@ -69,7 +69,7 @@ class ConvertColorSpace(IO.ComfyNode):
rgb = luma.unsqueeze(-1).repeat(1, 1, 1, 3) rgb = luma.unsqueeze(-1).repeat(1, 1, 1, 3)
rgb = srgb_to_linear(rgb) rgb = srgb_to_linear(rgb)
elif source_color_space == "HDR (Rec.2020)": elif source_color_space == "HDR Display (PQ/Rec.2020)":
# assuming Linear Rec.2020 input. Convert to Linear Rec.709 # assuming Linear Rec.2020 input. Convert to Linear Rec.709
matrix = M_2020_to_709.to(device) matrix = M_2020_to_709.to(device)
rgb = pq_to_linear(rgb) rgb = pq_to_linear(rgb)
@ -85,7 +85,7 @@ class ConvertColorSpace(IO.ComfyNode):
rgb = luma.unsqueeze(-1).repeat(1, 1, 1, 3) rgb = luma.unsqueeze(-1).repeat(1, 1, 1, 3)
rgb = linear_to_srgb(rgb) # reapply srgb gamma rgb = linear_to_srgb(rgb) # reapply srgb gamma
elif target_color_space == "HDR (Rec.2020)": elif target_color_space == "HDR Display (PQ/Rec.2020)":
# convert Gamut from Linear Rec.709 to Linear Rec.2020 # convert Gamut from Linear Rec.709 to Linear Rec.2020
rgb = torch.matmul(rgb, M_709_to_2020.to(device).T).clamp(min=0) rgb = torch.matmul(rgb, M_709_to_2020.to(device).T).clamp(min=0)
rgb = linear_to_pq(rgb) rgb = linear_to_pq(rgb)

View File

@ -963,12 +963,6 @@ class SaveImageAdvanced(IO.ComfyNode):
default="ComfyUI", default="ComfyUI",
tooltip="The prefix for the file to save. This may include formatting information such as %date:yyyy-MM-dd% or %Empty Latent Image.width% to include values from nodes.", tooltip="The prefix for the file to save. This may include formatting information such as %date:yyyy-MM-dd% or %Empty Latent Image.width% to include values from nodes.",
), ),
IO.Combo.Input(
"interept_as",
options=["Raw/Data", "sRGB"],
default="sRGB",
advanced=True,
),
IO.DynamicCombo.Input( IO.DynamicCombo.Input(
"format", "format",
options=[ options=[
@ -981,6 +975,12 @@ class SaveImageAdvanced(IO.ComfyNode):
default="8-bit", default="8-bit",
advanced=True, advanced=True,
), ),
IO.Combo.Input(
"interept_as",
options=["sRGB", "Linear", "Raw/Data"],
default="sRGB",
advanced=True,
),
], ],
), ),
IO.DynamicCombo.Option( IO.DynamicCombo.Option(
@ -992,6 +992,12 @@ class SaveImageAdvanced(IO.ComfyNode):
default="8-bit", default="8-bit",
advanced=True, advanced=True,
), ),
IO.Combo.Input(
"interept_as",
options=["sRGB", "Raw/Data"],
default="sRGB",
advanced=True,
),
], ],
), ),
IO.DynamicCombo.Option( IO.DynamicCombo.Option(
@ -1003,6 +1009,12 @@ class SaveImageAdvanced(IO.ComfyNode):
default="16-bit", default="16-bit",
advanced=True, advanced=True,
), ),
IO.Combo.Input(
"interept_as",
options=["Linear", "Raw/Data"],
default="Linear",
advanced=True,
),
], ],
), ),
], ],
@ -1025,7 +1037,7 @@ class SaveImageAdvanced(IO.ComfyNode):
# get widget values from dynamic combo # get widget values from dynamic combo
file_format = format["format"] file_format = format["format"]
bit_depth = format["bit_depth"] bit_depth = format["bit_depth"]
color_space = format["color_space"] interept_as = format["interept_as"]
img_tensor = image.clone() img_tensor = image.clone()