editing render results.

I would like to code something for blender, i could do it in c#, but then its only for windows people.
Since i like Both Linux and Android (thats possible), i rather write something that could be included in Blender.

Since Python lib PIL isnt included
I wonder how could one, open a render result (a png file), read a pixel, write a pixel and save the result as image
If i know these parts, i can write some math for noise removal for animations.
But i couldnt find any samples of python code


#open
img=bpy.data.images.load(filepath)

#get and set pixels
img.pixels[index]=value
#i.e. setting the first pixel of a rgba image
img.pixel[0]=red
img.pixel[1]=green
img.pixel[2]=blue
img.pixel[3]=alpha

#size and channels
img.size[0] #width
img.size[1] #height
img.channels #number of channels

#save
img.save() #to source
img.save_render(filepath)

Thanks !
I was also wondering the Z image depth, is there an option to include those in the png files.
As i now that png files support extra channels, since Z data would be an easy way to determine object bounderies

Since there is no option displayed in the GUI for saving extra channels there is probably no support of extra channels for the png format.

Although it is possible to access the render result as an image, there is no data attached to it . It is only possible to save it using the scene’s render settings. It is possible to change the render slot but i haven’t found any option to change/select the current render pass via python.


#render settings
bpy.data.scenes[scene.name].render.*
bpy.data.scenes[scene.name].render.image_settings.*

bpy.data.images['Render Result'].save_render(filepath,scene)

I have no clue wether it is possible to access the render result and its layers via python so i push this thread.

Maybe there is a guy who knows an answer to this.

EDIT: There is a FileOutputNode in the NodeEditor which may be used.

from what i know is that PNG doesn’t allow for channels other than RGBA, although there’s support for “private blocks”, but they can usually be read by the software that created them only. You may look into OpenEXR.