making text in front of an image always legible
From there, this approach would seem the most promising if we wanted to do something crazy like shrink the image down to 6 pixels by 4 pixels and potentially have text have a different color for each 16.7% stretch horizontally and each 25% stretch vertically: https://stackoverflow.com/a/21580560/1028376
A problem with that, and with any technique of doing this automatically where the first assessment of lightness or darkness of
Lots of answers are for background colors, not background images: