Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Tests to verify the count of colors returned matches the count requested #21

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Update readme.md
ijambro authored Mar 29, 2020
commit 776d464573a82cd4a177e1dfdd9ee3aef5e08cd2
12 changes: 12 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -53,6 +53,18 @@ getColors(filename, function (err, colors) {
})
```

The default number of colors returned is 5. You can specify a different number of colors by setting the pallet size before the call to getColors:

```js
const path = require('path')
const getColors = require('get-image-colors')

getColors.setPaletteSize(10)
getColors(path.join(__dirname, 'double-rainbow.png')).then(colors => {
// `colors` is an array of color objects
})
```

## How it Works

`get-image-colors` uses [get-pixels](http://npm.im/get-pixels) to create a pixel array, then extracts a color palette with [get-rgba-palette](http://npm.im/get-rgba-palette), which uses [quantize](http://npm.im/quantize) under the hood.