Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silhouette a PNG image using CSS

Anyone know of a way that I can get CSS to make a PNG image with transparency look completely blacked out like a silhouette?

In other words- Going from something like this:

http://susanbuck.net/upenn/examples/images/apple.jpg

To this:

alt text

It's for a lot of images which is why I'd like to avoid doing it via Photoshop.

like image 240
sbuck Avatar asked Nov 18 '10 13:11

sbuck


2 Answers

You can apply to the image style like filter: contrast(0%) brightness(50%) to get a silhouette. Do not forget prefixes.

like image 109
Johann Avatar answered Oct 14 '22 18:10

Johann


I don't see how it could be done with pure css. Javascript might be able to acheive it but you may consider using server side programming instead. With php you could make a duplicate of your original png on the server and replace the non-transparent pixels with a single color. It would be similar to a watermarking function.

like image 31
Dylan Avatar answered Oct 14 '22 19:10

Dylan