View Full Version : How to Invert White on Black Photo to Black on White?

03-19-2018, 01:35 PM

I have a bunch of images constantly coming in to the website which are white writings on black background.

I want to change it to black writings on white background. Would deeply appreciate if you can send me a link to a tutorial or a sample script.


03-19-2018, 02:55 PM
This is actually quite easily done in css:

filter: invert();

So you could give all of your white on black images a class name:

<img class="whiteonblack" src="whatever.jpg">

Then in your stylesheet have:

.whiteonblack {
filter: invert();

This can also be done in javascript, but this is simpler and uses the same css property. If you want to actually transform the image, so that you end up with an inverted image, you would need to use server side code. But this is simple and effective and support by almost all browsers.