# image-average-color

> Get the average color of an image

Latest version **1.0.0** (published 2016-06-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install image-average-color
pnpm add image-average-color
yarn add image-average-color
bun add image-average-color
```

Provides the command `average-color`.

## 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.0 |
| Published | 2016-06-18 |
| First published | 2016-06-18 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4.4.5 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Alexey Orlenko |
| Maintainers | aqrln |
| Keywords | image, color, average, jpg, jpeg, png, gif |

## Links

- npm: https://www.npmjs.com/package/image-average-color
- Repository: https://github.com/aqrln/image-average-color
- Homepage: https://github.com/aqrln/image-average-color#readme
- Issues: https://github.com/aqrln/image-average-color/issues
- npm.io page: https://npm.io/package/image-average-color

## Dependencies (1)

- [readimage](https://npm.io/package/readimage.md) ^1.1.1

## Alternatives

- [postcss-color-hex-alpha](https://npm.io/package/postcss-color-hex-alpha.md) — 6.4M weekly downloads
- [randomcolor](https://npm.io/package/randomcolor.md) — 348.0K weekly downloads
- [bows](https://npm.io/package/bows.md) — 1.3K weekly downloads
- [ep_prefer_color_scheme](https://npm.io/package/ep_prefer_color_scheme.md) — 260 weekly downloads
- [coc-yank](https://npm.io/package/coc-yank.md) — 61 weekly downloads

## Recent versions

- 1.0.0 (latest) — 2016-06-18

## README

image-average-color
===================

A simple library that calculates the average color of a PNG, JPG or GIF image.

The only exported function takes two arguments: first is either Buffer with image contents
or a filename, second one is a callback. Callback function should accept a possible error
and a color in form of array of four values in range 0...255 representing red, green,
blue and alpha channels.

```javascript
const average = require('image-average-color');

average('image.png', (err, color) => {
  if (err) throw err;
  var [red, green, blue, alpha] = color;
});

loadImageFromAstral((err, data) => {
  if (err) throw err;

  average(data, (err, color) => {
    if (err) throw err;
    var [red, green, blue, alpha] = color;
  });
});
```

This package also provides a command-line utility called `average-color` that accepts
a filename and prints the average color in CSS format:

```
$ average-color image.jpg
rgba(86, 219, 101, 1)
```

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