Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aqrln/image-average-color
https://github.com/aqrln/image-average-color
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/aqrln/image-average-color
- Owner: aqrln
- License: mit
- Created: 2016-06-18T03:35:04.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-06-18T03:44:32.000Z (over 8 years ago)
- Last Synced: 2024-10-09T20:19:23.262Z (about 1 month ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 5
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
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)
```