Socket
Socket
Sign inDemoInstall

image-average-color

Package Overview
Dependencies
6
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    image-average-color

Get the average color of an image


Version published
Weekly downloads
43
decreased by-58.65%
Maintainers
1
Install size
0.987 MB
Created
Weekly downloads
 

Readme

Source

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.

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)

Keywords

FAQs

Last updated on 18 Jun 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc