Load plotly figure with PIL without exporting as a file

Hi, I want to generate several plotly figures and then stitch them together using PIL (because plotly subplots works with traces but not whole figures). Is there a way how to hand the figure to PIL without having to export as png and read again? Currently PIL does not read plotly figures. Of course I donโ€™t need any interactivity, PIL should see the figure just as a png.

import plotly.express as px
from PIL import Image
figure = px.line([4,5])
Image.open(figure)

I donโ€™t see how this could be done without creating a png. You could write the png into a buffer without having to store it on disk, though.

I just found your answer here Render plotly figure as numpy ndarray of rgba pixels, this solves my problem. Converting to png is fine as far as I donโ€™t need to export the image as a file. Thanks!