# Why depth map renderings stored in 16-bit PNG turn out to be 8-bit?

I save my rendering results as 16-bit png files using Python as follow:

scene = bpy.context.scene
scene.render.image_settings.color_depth = '16'
scene.display_settings.display_device = 'sRGB'
scene.view_settings.view_transform = 'Raw'
scene.sequencer_colorspace_settings.name = 'Raw'
scene.use_nodes = True
for node in scene.node_tree.nodes:
scene.node_tree.nodes.remove(node)
renderNode = scene.node_tree.nodes.new('CompositorNodeRLayers')

depthOutputNode = scene.node_tree.nodes.new('CompositorNodeOutputFile')
depthOutputNode.format.file_format = 'PNG'
depthOutputNode.format.color_depth = '16'
depthOutputNode.format.color_mode = 'RGB'
depthOutputNode.base_path = 'somePath/'
depthOutputNode.file_slots[0].path = 'fileNameDepth#'

bpy.ops.render.render(write_still=True)


However, it seems that Blender stores/exports the rendering in a different format than I expected. I loaded the images in Python after rendering and I found out that the maximum value for all pixels is not more than 255 (8-bits). Does anyone know why this is the case? I wonder, would storing the depth maps in OpenEXR format resolve the issue?

• What pymodule are you using to open the image? It may not support 16 bit png. I see a 16 bit png saved here. Try opening the image in krita/blender and look at what the image format is. Do you have iv installed? - it is a utility from the openimageio project. Mar 31 '18 at 5:05
• @sambler I tried a couple of modules by they all assured me that the pixel values never go beyond 255. I tried imageio and scipy.ndimage.imread
– Amir
Mar 31 '18 at 14:47

It doesn't matter what the bit depth is if the format is output referred. 32, 16, and 8 bit integer, and even in float instances, may result in output referred ranges, typically 0.0 to 1.0. In these instances, the bit depth doesn't increase the range, merely the number of steps between them.

The only real option would be a float format that supports deeper data ranges such as EXR or TIFF. Blender's TIFF support did not appear to support float instances when last examined, and even if it did it may be bound to output referred ranges.

• While true, that isn't the issue. Blender is being told to save a 16bit image but when opened it appears to be only 8bit. Mar 31 '18 at 7:55
• What does a referred output mean here? Do you mean that the values are "clamped"? So based on your response, the only way I can get depth maps whose range is realistic is by outputting my rendering results as OpenEXR. Is that correct?
– Amir
Mar 31 '18 at 14:44
• If you are attempting to save scene referred emissions or data beyond the 0.0 to 1.0 range, EXR is the only valid option. PNG is a cancer of a format for other reasons as well. Mar 31 '18 at 15:07
• EXR is the only format that will allow you to save the Z-pass unadulterated.
– user1853
Mar 31 '18 at 15:45
• @troy_s Thanks for your answer. As explained here I cannot currently save my rendering results in OpenEXR format. Could the HDR format be a good alternative for now? Could you also take a look at this question? I have a pretty strong feeling that the uninterpretability issue is highly tied to the problem here.
– Amir
Mar 31 '18 at 19:02