I was wondering if anyone knew of a way to recolor an image using JavaScript. Any type of access to an image's pixels would work, I suppose, as long I could read/write color values. It should work in Firefox; if it doesn't work in IE, no big deal, but it would be a benefit if it did.
Thank you for your help!
You could change the image using canvas.
There are dozens of examples online of changing images to grayscale. There shouldn't be any reason you can't change the colours to something different.
In addition to alex's answer (eg: to use <canvas>
, which is not yet widely supported - cough IE cough), you can use JS to change an image to another and give the illusion that it's just the same image, recolored. The other image can be readily available or can be created by the server on the fly if your server-side language supports image manipulation (eg: PHP can do it with GD).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With