Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

image-average-color

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

image-average-color

Get the average color of an image

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
82
decreased by-52.87%
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 18 Jun 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc