In a work project, the UI guys had defined large parts of the interface as text over image. To improve legibility, I experimented with ways to automatically darken an image based on its original brightness.
You can hover over an image to view it without the overlay, and see the percentage brightness found by the calculation.
Credits to matkl for the "average" color calculation and to Franci Penov for the brightness calculation based on that color.
Demo : https://antoningrele.github.io/img-brightness-normalization/