Problem saving render image in 2.71

I was going to use the auto_render_save add-on. However it only saved white PNG images,

Then I tried to the same “manually” via “Run Script” using the short script below (after rendering a small image).
However, it did not work either (also white PNG images).


import bpy
scene = bpy.data.scenes[0]
image = bpy.data.images['Render Result']
print(image.has_data)
print(image.render_slot)
print(image.source)
image.save_render(filepath = '/tmp/test.png', scene = scene)

Terminal output:

True
0
VIEWER

I did some permutations, e.g. omitting the “scene” value, also without success.

Switching the slot will change the number.

Replacing save_render by image.save() reports:

RuntimeError: Error: Image ‘Render Result’ does not have any image data

What am I missing?

RuntimeError: Error: Image ‘Render Result’ does not have any image data

The problem has been solved.

If you look closely, the command print(image.souce) results in “VIEWER” (not “GENERATED”).

VIEWER seems to refer to the Viewer Node of the compositor.
The compositor wasn’t set-up (“use node” was not enabled).

A normal render had generate a picture in the image editor, but not the Viewer Node, as there was none.
After enableing the compositor, the command works as expected.

I’m not sure if this is intentional or not, but it is unexpected.