# domcolor

> Get the dominant color from an image

Latest version **1.0.1** (published 2022-04-17) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2022-04-17 |
| First published | 2020-07-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 7.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Michael Sterpka |
| Maintainers | msterpka |
| Keywords | dominant, color, js |

## Links

- npm: https://www.npmjs.com/package/domcolor
- Repository: https://github.com/mster/domcolor
- Homepage: https://github.com/mster/domcolor#readme
- Issues: https://github.com/mster/domcolor/issues
- npm.io page: https://npm.io/package/domcolor

## Dependencies (1)

- [image-decode](https://npm.io/package/image-decode.md) ^1.2.2

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.1 (latest) — 2022-04-17
- 1.0.0 — 2022-04-17
- 0.0.2 — 2021-05-11
- 0.0.1 — 2020-07-13
- 0.0.0 — 2020-07-13

## README

# domcolor

Get the dominant color from an image.

## Installation

```sh
npm install domcolor
```

## Usage

```js
const domcolor = require('domcolor')
```

Pass path to image file or image file as a buffer.

```js
const dominantColor = await domcolor('path/to/img.jpg')
// Or
const fromBuffer = await domcolor(imageBuffer)
```

## API

### `domcolor (img)`

- `img`: `<string>` | `<Buffer>` (Required)

  The string path to the source image or the source image in buffer form.

- Returns: `<Object>`

  - `rgb`: `<Array>` color RGB values
  - `hex`: `<string>` color in hex format
  - `count`: `<integer>` the number of pixels are the dominant color
  - `total`: `<integer>` the total number of pixels in the image

## Example

![gopher](https://user-images.githubusercontent.com/15038724/87260970-2f284580-c469-11ea-844b-f0cd5d8b0277.png)

```js
{ rgb: [ 208, 182, 152 ], hex: 'd0b698', count: 23210, total: 65536 }
```

![gopher-color](https://user-images.githubusercontent.com/15038724/87261182-1cfad700-c46a-11ea-9902-0ffe49c1511b.png)

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