Socket
Book a DemoInstallSign in
Socket

avg-color-gen

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

avg-color-gen

Tired of slecting background colors for your images? use avg-color-gen. Just pass an image of your choice and it will give you an avg color by scanning the image.

1.0.3
latest
Source
npmnpm
Version published
Weekly downloads
1
-85.71%
Maintainers
1
Weekly downloads
 
Created
Source

Prerequisies

A very simple lightweight package that calculates the average color of any images in browser environment.

  • Image must be passed in a base64 format
  • It is not meant to process video files directly, but a work around for that would be, print a single frame of video on and then convert it into base64. Then pass the resulting base64 to getAverageColor

Usage

  • Installing the package
npm install avg-color-gen --save

  • Importing the module
import getAverageColor from "avg-color-gen"
  • Calling the function
getAverageColor(IMAGE_IN_BASE64, OPACITY OF THE RESULTING COLOR);


// Example with callbacks
// NOTE: requiring an image in js gets it in base64
getAverageColor(require(`../assets/img/never_gonna_gice_you_up.png`), 0.09).then((rgb) => {
    updateRGB(rgb);
})

Responses

  • In case of success, it will return
{
    status: "success",
    color: "rgba(x,x,x,x)"
}
  • In case of failure, it will return
{
    status: "failure",
    reason: "SOME_REASON_HERE"
}

Keywords

fast

FAQs

Package last updated on 19 Aug 2021

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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.