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:

#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'

# 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

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


2 Answers 2


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
  • $\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$ Nov 28, 2017 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, 2017 at 19:12

I always use img.save(), it doesn't work.

Although it could export exr files, it couldn't use imag_settings to set things like bit depth and encodingType, so my data never exceeded [0,1].

I spent a day looking for the official blender documentation, but I couldn't find the relevant function, so this is the solution

set image_settings with the bpy.context.scene.render,and use render_save to export file.

Anyone wants to export exr correctly according to their own requirements, the following code may give you an idea.

image_settings = bpy.context.scene.render.image_settings
    image_settings.file_format = "OPEN_EXR"
    image_settings.color_depth = '32'
    image_settings.compression = 0
    image_settings.exr_codec = "ZIP"
    image_settings.color_management = 'OVERRIDE'
    image_settings.color_mode = 'RGBA'


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .