Isha
Isha

Reputation:

How to change the colour on the image?

If I click on the image it should be changed the color of the part of the image.Then I want to replace the image.Can it be done using javasript? Pls help me.

Upvotes: 0

Views: 426

Answers (4)

Bjorn
Bjorn

Reputation: 71830

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

Upvotes: 0

doug
doug

Reputation: 127

Unless i misunderstood i think you could probably place a transparent image above the image you wanted to change, thereby kind of changing the appearance of the image. I think i did something like this with prototype once.

Upvotes: 0

ericteubert
ericteubert

Reputation: 4591

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

https://www.php.net/manual/en/book.image.php

Upvotes: 0

Ólafur Waage
Ólafur Waage

Reputation: 69991

JavaScript can't change physical images like .jpg, .png or .gif (to my knowledge) But replacing images is easy.

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

Upvotes: 2

Related Questions