'Python - Multiple images to multilayered .xcf

I have three PIL images of the same size in RAM (no disk here). They represent different frequencies (details, shadow, mask).

Is it possible to overlay these images into a .xcf file to further process them by hand in gimp? If so, can the opacity of the layers be controlled before saving the image?

I'm ideally looking for a python solution.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source