3
$\begingroup$

I'd like to create a picture in blender and save it as a 32 bit exr.

import bpy

# in case of re-runnign this code, 
# get the old 'foo' image out of the way 
if 'foo' in bpy.data.images:
    bpy.data.images['foo'].name='bar'

#create an HDR image with name 'foo'
bpy.ops.image.new(name='foo', width=512, height=512, alpha=False, float=True)

#find the image with name 'foo'
image=bpy.data.images['foo']

# set it up for saving an exr HDR image
image.filepath_raw =  '/tmp/foo.exr'
image.file_format = 'OPEN_EXR'
# TODO here: image.save_as_32_bit=True (instead of 16)

#save image to disc
image.save()

The above code makes 16 bit exr according to imagemagick. I want to use bpy.ops.image.save_as somehow from python, in conjuction with this code, to emulate the behaviour of Image->Save as Image with the option [Float (Full)] rather than [Float (Half)]

The Save as dialogue points to a thing called ImageFormatSettings. Where can I supply this in python?

save as image dialogue

Thank you

$\endgroup$
2
$\begingroup$

You can change the color depth like this:

image_settings = bpy.context.scene.render.image_settings
image_settings.file_format = "OPEN_EXR"
image_setting.color_depth = '32'

Note that '32' is a string and not an integer/float. Then save the image like this:

img = bpy.data.images['myImage'] # your image here
img.save_render("C:\\Users\\daddy\\me\\Documents\\myImage.exr") # save to desination
$\endgroup$
  • $\begingroup$ this does not work for me -> [enum '32' not found in ('8', '16')] also, the question is about how i can save the image with 32 bit, I don't think setting the color depth in the renderer will solve the problem (the image internally is already 32 bit). Please elaborate if i am wrong. $\endgroup$ – Madlaina Kalunder Nov 28 '17 at 17:23
  • $\begingroup$ Updated answer. If you use save_render instead of ops, it will use the scene's image settings. The error you got was because it has to be set to EXR before you can access the 32 bit option(my bad). $\endgroup$ – cmomoney Nov 28 '17 at 19:12

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.