2

I have this image: enter image description here.

I need to gray it out to look like this: enter image description here.

Using the response in this SO question: Gray out image with CSS?

 opacity : 0.4;
 filter: alpha(opacity=40); /* msie */

I get this: enter image description here

Setting the filter property to filter: grayscale(100%) still leaves changes in the colors: enter image description here

Anyway I can make it completely gray?

Community
  • 1
  • 1
TheOne
  • 10,819
  • 20
  • 81
  • 119

2 Answers2

1

It sounds like you are trying to change the actual pixels in an image. I believe what you are looking for is something like.

Pixastic (coloradjust)

https://github.com/jseidelin/pixastic

http://www.pixastic.com/lib/docs/actions/coloradjust/

or PaintbrushJS (colour tint)

https://github.com/mezzoblue/PaintbrushJS

http://mezzoblue.github.com/PaintbrushJS/demo/

nate_weldon
  • 2,289
  • 1
  • 26
  • 32
  • nate_weldon, PaintBrushJS did the trick with colour tint, but it only works on page loads. Do you know how I can change it programmatically after page loads (with a mouse click)? – TheOne Jan 05 '13 at 19:49
1

You won't be able to do this with CSS. You need to process the image first in one way or another to get a solid gray where gradients are removed.

The better approach is to make a version of it as you want it and then using css/js replace the color version with the processed version.

The other option is to process it using the canvas and convolutions or go by pixel by pixel.

Pixel approach is not the fastest kid on the block however:
http://www.onaluf.org/en/entry/13

But perhaps processing it by using various techniques can give you what're after:
http://www.html5rocks.com/en/tutorials/canvas/imagefilters/