3
$\begingroup$

I'm running Blender 2.79:

/path/to/blender -b empty.blend -P script.py

With script.py:

import numpy as np
import bpy

x, y = 100, 100
print("rendering")
bpy.ops.render.render()
res = bpy.data.images['Viewer Node']
print(len(res.pixels[:]), x*y*4)
arr = np.array(res.pixels[:]).reshape((y, x, 4))

empty.blend is a simple scene (camera+cube+light) with render settings at 100px by 100px @ 100%, with compositing nodes:

enter image description here

I get an error because res.pixels[:] has length 262144 (= 256 * 256 * 4) when it should be 40000 (= 100 * 100 * 4). Moreover, res.pixels[:] is all zeros.

If I run Blender without -b, it works.

$\endgroup$

Your Answer

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

Browse other questions tagged or ask your own question.