JQuery - How to brighten an image

Hi
In jQuery, we can use the code as shown below to make the image dark. Otherwise, how can we draw an image?

$(this).hover(function() {
    $(this).stop().animate({ opacity: 0.5 }, 500);
},
function() {
    $(this).stop().animate({ opacity: 1.0 }, 500);
});
+3
source share
1 answer

I would use Pixastic . It has jQuery bindings if you want to use this route.

You can lighten or darken the image as follows:

var img = new Image();
img.onload = function() {
    Pixastic.process(img, "lighten", {amount:0.5});
}
document.body.appendChild(img);
img.src = "myimage.jpg";

You can fake this effect by changing the opacity of the image, making sure that the background behind the image is white.

+7
source

Source: https://habr.com/ru/post/1795655/


All Articles