How to hook up an Image to a CompositorNodeImage?

I’m writing an add-on and would like to automatically create a CompositorNodeImage and populate it appropriately. I’m having a difficult time figuring out how to attach an image to the node’s image property. I’ve got the file name (in the case of a single image) or file path (in the case of a image sequence) but I can’t seem to figure out the correct syntax to feed that information into a CompositorNodeImage. (Nor can I find an example in Blender’s files or online.)

Can someone post a working example of how to do this? Thanks!

It’s pretty much like anywhere else, you create a new material data block by loading an image from file, then use that image for the node.

import bpy

comp = bpy.context.scene.node_tree
composite = comp.nodes['Composite']

node = comp.nodes.new("CompositorNodeImage")

fp = r"C:\Path	o\file.ext"
img = bpy.data.images.load(fp)
node.image = img

comp.links.new(node.outputs['Image'], composite.inputs['Image'])