GithubHelp home page GithubHelp logo

gerbyzation / get-image-colors Goto Github PK

View Code? Open in Web Editor NEW

This project forked from colorjs/get-image-colors

0.0 2.0 0.0 216 KB

Extract colors from GIF, PNG, JPG, and SVG images

JavaScript 100.00%

get-image-colors's Introduction

get-image-colors

Extract colors from images. Supports GIF, JPG, PNG, and even SVG!

example color palette

Installation

npm install get-image-colors --save

This package is intended for use in node environments. It won't work in a browser because it has node-specific dependencies.

Usage

const getColors = require("get-image-colors")

getColors(__dirname + 'double-rainbow.png', function(err, colors){
  // colors is an array of colors
})

colors is an array of chroma.js color objects. chroma.js objects have methods that lets you pick the color format you want (RGB hex, HSL, etc), and give you access to powerful color manipulation features:

colors.map(color => color.hex())
// => ['#FFFFFF', '#123123', '#F0F0F0']

colors[0].alpha(0.5).css();
// => 'rgb(0,128,128)''

How it Works

get-image-colors uses get-pixels to create a pixel array, then extracts a color palette with get-rgba-palette, which uses quantize under the hood.

Colors are converted from get-rgba-palette's flat array format into chroma.js color instances.

Tests

npm install
npm test

Dependencies

  • chroma-js: JavaScript library for color conversions
  • get-pixels: Reads the pixels of an image as an ndarray
  • get-rgba-palette: gets a palette of prominent colors from an array of pixels
  • get-svg-colors: Extract stroke and fill colors from SVG files

Dev Dependencies

  • mocha: simple, flexible, fun test framework

License

MIT

get-image-colors's People

Contributors

millette avatar zeke avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.