Page MenuHome

Pixels and resolution not for multilayer EXR and Render Result
Open, NormalPublic

Description

System Information
CentOS - GTX 1070

Blender Version
2.79

Short description of error
Pixels and resolution are not available with multilayer EXR or Render Result images.

Exact steps for others to reproduce the error
import bpy
data = bpy.data
image = data.images['Render result or multilayer EXR']
print(image.pixels) # length is 0
print(image.resolution) # return always Vector((0.0, 0.0))

It is working with regular EXR file.

Details

Type
To Do

Event Timeline

true. dont know if you know this already, but a workaround for now could be this
can have a look (, but not sure how involved this task will end up being...)

Brecht Van Lommel (brecht) triaged this task as Confirmed, Medium priority.

@Philipp Oeser (lichtwerk), since you claimed this task, are you working on a solution?

This is indeed a gap in our Python API that would be good to fix, though not strictly a bug so up to you if you want to close it or fix it.

@Brecht Van Lommel (brecht): yep, I'm behind schedule here, but I will have a look later today

OK, had a first look, but there are remaining questions that I have to wrap my head around.

Getting pixels or size would require aquiring an ImBuf, however the way it is normally done involves an ImageUser (that in turn would have information regarding the corresponding scene, layer, pass, renderslot).
We dont have that from python and I am unsure on what to use as default here. (which scenes renderlayer? which pass, slot?)

And I am still looking at how this "Render Result" is stored in the main database "images". e.g. different scenes RenderResults can have different sizes, however other properties (e.g. display_aspect) are shared across scenes renderResults as it seems...

Long story short: needs a bit more time -- I know, I'm slow... :)

Unfortunately I'll only be able to look at this in April again, so let others take over....

Brecht Van Lommel (brecht) claimed this task.

This is really a known to do item and not a bug, so closing, feature requests are handled elsewhere.

Philipp Oeser (lichtwerk) lowered the priority of this task from Confirmed, Medium to Normal.

also added to TODO here: https://wiki.blender.org/index.php/Dev:Source/Development/Todo/Scripting
Will have look again if time permits

Philipp Oeser (lichtwerk) changed Type from Bug to To Do.Apr 19 2018, 1:08 PM

I'm currently in a bind at work, and this would be tremendously helpful. I need to access Render Result pixels, and the most lightweight way to do so would be to access them directly. Performance is highly critical for the job at hand, and using GPU offscreen techniques proved to be quite inefficient.

I am willing to help out in this particular task, although it would be my first commit to Blender. I'll become more informed on how to properly contribute code to Blender now, and then try to fix this issue. I'll comment again if I'm blocked somewhere!

Managed to do it, but it is a hacky solution, so hacky that I'm just gonna post it here instead of actually going through with a commit.

Basically the fact that the Render Result has no ImageUser makes the ".pixels" query to return empty. To mitigate this I did the following:

https://github.com/dfelinto/blender/pull/48/files

I used an available fork on GitHub to simplify the process. This commit outlines what was done, but it was basically add an ImageUser to the Image struct, and that ImageUser is assigned to in the OpenGL render init phase. In the image_get_render_result, where this function returned null previously, it now uses the new ImageUser assigned to the Image as a way to get render and scene information.

It's really hacky, but it might help other people :)