Makes an image's background pixels transparent. Replaces img
with canvas
.
npm install --save translucify
Use the flood-fill method for making the background transparent.
selectorResult | |
---|---|
Type | Example |
jQuery object | $('img:last-child') |
NodeList | document.querySelectorAll('img') |
HTMLImageElement | document.querySelector('img#product') |
tolerance
is a value from 0 to 1 that determines which pixels are part of same group of pixels to be flooded with transparency. Default value: 0.05
Example: drop-in usage
<html>
<head>
<script src="//path/to/libs/translucify.js"></script>
...
</head>
<body>
...
<img src="cheese1.jpg"/>
...
</body>
</html>
window.translucify($('img'));
Example: Browserify usage
var translucify = require('translucify');
...
translucify(document.querySelectorAll('img'));
npm start
npm install
grunt