I have figures which I use in several places, some of them in dark context and some of them light (for example, a my obsidian vault is dark but a PDF of my thesis is light). As such, some of the figures are colored to work in a dark environment, and some in light.
But sometimes I want to take a figure from a dark context and use it in a light context, or vice versa. So far I have created a copy of the figure for the light/dark mode by simply inverting the colors. I use color schemes in which this looks mostly fine.
But manually inverting the colors and saving a copy is exhausting, and inefficient. I want to do this automatically, and possibly without saving a copy of the original figure.
Is there a way to invert the colors of a figure while compiling the output of a latex document?
Thanks a lot!
Edit: I saw this question, but the answers were basically "you can't". Since the answers are unsatisfactory and the question is VERY old, I thought it would be best to open a new one. But if this is not the custom here, please let me know and I'll ask there instead.

decodearrayoption: https://tex.stackexchange.com/questions/300334/false-colour-coding-in-an-image/300355#300355 – Steven B. Segletes Aug 26 '23 at 12:02