Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JQuery change hue, saturation, gamma of <img>?

I want to make an image darker if you hover your mouse over it. Is it possible to change the hue, saturation or gamma of an img with JQuery (or Javascript)?

like image 207
Tomkay Avatar asked Nov 10 '10 10:11

Tomkay


3 Answers

Have you tried PaintbrushJS or Pixastic library?

like image 163
niksy Avatar answered Oct 14 '22 15:10

niksy


Show and hide a semi-transparent black <div> over the top of the image.

like image 22
Marcelo Cantos Avatar answered Oct 14 '22 13:10

Marcelo Cantos


It is not possible to do this using only JavaScript (since it can't manipulate binary files), however you can do this with the HTML5 <canvas> element to help.

Take a look here, there are some libraries out there to help.

If you just want to fade it, change the opacity on hover, for example:

$("img").css({ opacity: 0.5 }).hover(function() {
  $(this).animate({ opacity: 1 });
}, function() {
  $(this).animate({ opacity: 0.5 });
});
like image 35
Nick Craver Avatar answered Oct 14 '22 13:10

Nick Craver