You could color-sample the pictures displayed on the fly with a library like color-thief[0] and render the text in some acceptable contrasting color. We do something similar for a bit of our app that allows the users to set color schemes.
Nice library! All javascript too. Thanks for the heads up - will certainly make an interesting project to use this to calculate the text colour for the error screens.
In fact, I may be able to go back to using coloured Unsplash images. I went for Grayscale images purely so that I could stick to white text for the contrast.