Changing color management render in Python


Hi everyone !

I need some help because I’m creating a script who open the renderview, start the render, and save the render in PNG image. But everytime my PNG image output is darken than my render. It’s because my script save my image with the “Save Raw Image” option checked and I want my script to save my image in “Save Color-Managed Image” option to have the same color management in my render and in my final PNG image ? Do you know what’s the command to do that please ? Thank you !


Here’s an example, you might want to also save the current viewTransformName, set it to what you expect (like ‘sRGB gamma’), then restore at the end. You can also check out renderWindowPanel.mel in your maya install /scripts/others directory for more clues.

import maya.cmds as cmds
import as createImageFormats

formatManager = createImageFormats.ImageFormats()
cmds.renderWindowEditor('renderView', e=True, colorManage=True, writeImage='path/to/file.png')


Hi ! Thanks for you answer. I tried everything you said but I still have the same error. Even when I save my image in JPEG. I think that maybye my problem is because i’m launching the render with arnold (always in my script). So maybye the arnold render settings don’t match with the basic renderView of Maya, I don’t know. Here is my script :

#Save the image------------------------------------------------------
import maya.mel as mel
import as createImageFormats
formatManager = createImageFormats.ImageFormats()
imagePath = cmds.internalVar(upd=True)+“scripts/HShaders_script/Icons/Shaders/” + self.CBoxCategory.currentText() + “/” + self.lineEditName.text()+".png"
cmds.colorManagementPrefs(e=True, viewTransformName=“sRGB gamma”)
cmds.renderWindowEditor(‘renderView’, e=True, colorManage=True, writeImage=imagePath)


Ok so my problem has been resolved. All I had to do is to open the renderview by using : mel.eval(‘RenderViewWindow’)
I don’t really know why but when the renderview is opened, the PNG image saved will not be RAW and it will be as the same color of the render.