# translucify

> Makes uniform color image backgrounds transparent. Replaces with .

Latest version **0.1.5** (published 2015-06-05) · ISC license · 0 weekly downloads

## Install

```sh
npm install translucify
pnpm add translucify
yarn add translucify
bun add translucify
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2015-06-05 |
| First published | 2015-05-01 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 29 |
| Author | Jim Yang @ ThisPlace.com |
| Maintainers | jim-thisplace |
| Keywords | transparency, image, canvas, pixels, translucify, replace, dom |

## Links

- npm: https://www.npmjs.com/package/translucify
- Repository: https://github.com/ThisPlace/translucify
- Issues: https://github.com/ThisPlace/translucify/issues
- npm.io page: https://npm.io/package/translucify

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.1.5 (latest) — 2015-06-05
- 0.1.4 — 2015-05-01
- 0.1.3 — 2015-05-01
- 0.1.2 — 2015-05-01

## README

# Translucify
Makes an image's background pixels transparent. Replaces `img` with `canvas`.

## Installation and Usage

```bash
npm install --save translucify
```

### translucify(_selectorResult_, _tolerance_)

Use the flood-fill method for making the background transparent.

<table>
  <thead>
    <tr><th colspan="2"><i>selectorResult</i></th></tr>
    <tr>
      <th>Type</th>
      <th>Example</th>
    </tr>
  </thead>
  <tbody>
    <tr>
        <td>jQuery object</td>
        <td><code>$('img:last-child')</code></td>
    </tr>
    <tr>
        <td><a href="https://developer.mozilla.org/en/docs/Web/API/NodeList">NodeList</a></td>
        <td><code>document.querySelectorAll('img')</code></td>
    </tr>
    <tr>
        <td><a href="https://developer.mozilla.org/en/docs/Web/API/HTMLImageElement">HTMLImageElement</a></td>
        <td><code>document.querySelector('img#product')</code></td>
    </tr>
  </tbody>
</table>

`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
<html>
    <head>
        <script src="//path/to/libs/translucify.js"></script>
        ...
    </head>
    <body>
        ...
        <img src="cheese1.jpg"/>
        ...
    </body>
</html>
```

```javascript
window.translucify($('img'));
```

*Example: Browserify usage*

```javascript
var translucify = require('translucify');

...

translucify(document.querySelectorAll('img'));
```

---

## Creating the reference image for testing

```bash
npm start
```

## Running the test

```bash
npm install
grunt
```

---
_Source: https://npm.io/package/translucify · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
