2
$\begingroup$

When accessing pixel data of a bpy.types.Image object, I only get the color information of the image before the color management settings are applied. This is regardless of whether the "View as Render" option is enabled or not. If I choose this option in the image editor, however, the image is displayed with the color management applied. So, the pixel data must exist somewhere in memory.

Is there a way to get the pixel data AFTER the color management settings have been applied via python?

Or alternatively: Is there a way to apply the color management settings to the pixel data manually? (maybe via OpenColorIO?)

$\endgroup$
6
  • 1
    $\begingroup$ No. There has been a need for an OpenColorIO node for over a decade now. $\endgroup$
    – troy_s
    Jan 3, 2021 at 16:52
  • $\begingroup$ Thanks for the answer, @troy_s. Bad though. But if Blender relies on OpenColorIO, are you aware of any linked library that is shipped with Blender? If there is one, directly calling this via ctypes would be an option. Unfortunately, I couldn't find one, but maybe I overlooked it!? $\endgroup$
    – reg.cs
    Jan 3, 2021 at 17:00
  • $\begingroup$ I would think you could add on something via Python. $\endgroup$
    – troy_s
    Jan 4, 2021 at 14:20
  • $\begingroup$ Thanks for your thoughts, troy_s. $\endgroup$
    – reg.cs
    Jan 8, 2021 at 13:58
  • $\begingroup$ Any time. I wish I could be more helpful here, but I don’t have much time to tinker with Blender Python APIs and such. Happy to help you out by checking the code / script if you invest some time into this. If you write up an actual node, I could see it possibly (?) getting merged? But that’s up to the Aristomeritocracy. $\endgroup$
    – troy_s
    Jan 8, 2021 at 18:55

1 Answer 1

1
$\begingroup$

The only way I know to do this is:

  1. create a temp scene
  2. set the temp scene's color management as desired
  3. save the image with image.save_render(path, scene=tmp_scene)
  4. read the file at path back in as an image and access its pixels

Maybe someone else will have a better answer though.

$\endgroup$
3
  • $\begingroup$ Thanks for the suggestions. But this is actually something I would like to avoid. If one would like to do it like that, the more direct way of this work around would probably also be using the save_as() method of the bpy.types.Image. However, I would really like to have a more direct way, if this is possible. $\endgroup$
    – reg.cs
    Jan 2, 2021 at 19:01
  • $\begingroup$ Yeah, it's not nice. You can use save_render, I'd forgotten about that. $\endgroup$
    – scurest
    Jan 2, 2021 at 19:15
  • $\begingroup$ Is there maybe a chance to use OpenColorIO directly from within a Blender add-on? $\endgroup$
    – reg.cs
    Jan 3, 2021 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.