spacepxl / ComfyUI-HQ-Image-Save

Load/save images and latents as 32bit EXRs
MIT License
44 stars 6 forks source link

R & B channeles swapped #6

Closed NicTanghe closed 5 months ago

NicTanghe commented 5 months ago

Hello when i save a file using your great adition. the colours seem way of in comarison to the png that is rendered and the input.

My red floor is turning blue. The red and blue channels are swapped in my exr ?

gamma on png vs plain_exr image

swapped blue and red channel vs plain_exr image

spacepxl commented 5 months ago

I'm not sure how you've handled the round trip through comfy, but here's a few notes that might help you to troubleshoot it.

  1. Comfy works in sRGB space, but floating point. So if you have linear plates, like EXRs should be, they have to be converted to sRGB to use in comfy. The load nodes have an option to enable or disable this conversion, so you can bake your own color transform into the file if you don't want to use the sRGB conversion. The save nodes have the inverse operation, sRGB to linear. Unfortunately there's no way around the fact that the linear-sRGB-linear conversion will clip 0 and 1. If you want to preserve highlights > 1, you'll need to bake your own color conversion into the EXR to compress the highlights down into the 0-1 range, whether that's a log conversion, custom curve, etc depending on your needs.
  2. The nodes use OpenCV to read and write EXRs, and OpenCV is a bit funky because it uses a BGR channel order. I've handled that within the nodes, so it should all convert correctly. I suspect your color issue is actually a clipping issue, but I can't be sure. If it is actually a channel order issue, please let me know how to reproduce it. It might be helpful to test with a more colorful image to make it clear.
  3. Color difference between EXR and PNG could depend on your nuke color config. If you're using ACES or anything else with manipulated primaries, good luck, and check that your EXR and PNG are both coming in with the correct color space.
NicTanghe commented 5 months ago

It is definitely a channel order issue.

Might be a bad actor with access to my system messing with my files. Below is my workflow inpaint_Tanghe.json

spacepxl commented 5 months ago

I think I found the issue. You're not using any of my nodes, you're using a node from Marigold, which doesn't handle BGR correctly, and doesn't handle sRGB conversion.

image

These are the EXR save nodes from this repo: image

NicTanghe commented 5 months ago

Ow thx so much for helping me with this. I thought it WS a legit bug sry.