Create an image node via code I tried to create an image node in blender with cycles renderer enabled.

My first attempt looks like this:

import bpy
mat = bpy.data.materials["Material"]

nodes = mat.node_tree.nodes
material_output = nodes.get("Material Output")

image = bpy.types.Image(file_format='PNG')
image.file_format = 'PNG'
image.filepath = 'C:\\Users\\Standardbenutzer\\Desktop\\bla.png'

node_texture = nodes.new(type='ShaderNodeTexImage')
node_texture.image = image
node_texture.location = 0,200

links = mat.node_tree.links
link = links.new(node_texture.outputs[0], nodes.get("Diffuse BSDF").inputs[0])


If i execute this code i get the error message:


  Traceback (most recent call last):
    File "\Text", line 7, in 
  TypeError: bpy_struct.new(type): expected a single argument
  Error: Python script fail, look in the console for now...


In the blender docs i found this:

http://www.blender.org/api/blender_python_api_2_72_1/bpy.types.Image.html#bpy.types.Image

the constructor asks for a ID but even if i set something like 0 i get the same message.
This is how you add image:

import bpy

path = "path_to_the_image"

try:
    img = bpy.data.images.load(path)
except:
    raise NameError("Cannot load image %s" % path)