2
$\begingroup$

I have trouble to get a script working within Blender 2.8. What is the correct way to change Color Space mode of an image texture node?

node_opacity = nodes.new(type="ShaderNodeTexImage")
node_opacity.colorspace_settings.name = "Linear"

enter image description here

$\endgroup$
3
$\begingroup$

The colorspace is shown from the image data, it is not a node property.

node_opacity.image.colorspace_settings.name = 'Linear'
$\endgroup$
  • $\begingroup$ Wow.. I wouldn't expect to have to reach for the string value of its name.. $\endgroup$ – Robin Betts Jun 25 at 13:38
  • 2
    $\begingroup$ @RobinBetts despite the name, it is an enum. Will throw an error if you set it willy nilly enum "willynilly" not found in ('Filmic Log', 'Linear', 'Linear ACES', 'Non-Color', 'Raw', 'sRGB', 'XYZ') $\endgroup$ – batFINGER Jun 25 at 16:46
  • $\begingroup$ Thank you for the command, but when I set the image to Linear my normal map baked becomes black it loses all his informations. $\endgroup$ – Danyl Bekhoucha Sep 30 at 11:25
0
$\begingroup$

If you would like to reference it with the node property, you can do

bpy.data.materials[0].node_tree.nodes['Image Texture'].image.colorspace_settings.name='Linear'
$\endgroup$

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.