How do I change the color in the image?

If I click on the image, it should change the color of a part of the image. Then I want to replace the image. Can this be done with javasript? Help me.

0


a source to share


4 answers


JavaScript cannot modify physical images like .jpg, .png, or .gif (as far as I know). But replacing images is easy.



document.getElementById("foo").src = "example.jpg";

      

+2


a source


If you mean changing the color of a clicked pixel, this is not only possible with JavaScript. But you can get coordinates and pass them to PHP script. In PHP, you can change the image.



http://de2.php.net/manual/en/book.image.php

0


a source


If I didn't get it, I think you could place a transparent image over the image you wanted to change, thereby changing the appearance of the image. I think I did something like this with prototype once.

0


a source


As far as changing the color, yes it can be done, you could probably cook something with SVG as well as Canvas element and JavaScript using your image.

0


a source







All Articles