All Projects β†’ luukdv β†’ Color.js

luukdv / Color.js

Licence: mit
Extract colors from an image (0.75 KB) 🎨

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Color.js

leeks.js
Simple ANSI styling for your terminal
Stars: ✭ 12 (-71.43%)
Mutual labels:  color, colors, rgb
Html To Image
βœ‚οΈ Generates an image from a DOM node using HTML5 canvas and SVG.
Stars: ✭ 595 (+1316.67%)
Mutual labels:  image, picture, canvas
anypalette.js
🎨 Read/write all color palette file formats β€πŸ§‘πŸ’›πŸ’šπŸ’™πŸ’œ
Stars: ✭ 41 (-2.38%)
Mutual labels:  color, palette, colors
Atgmediabrowser
Image slide-show viewer with multiple predefined transition styles, with ability to create new transitions with ease.
Stars: ✭ 186 (+342.86%)
Mutual labels:  image, photo, browser
Picassopalette
Android Lollipop Palette is now easy to use with Picasso !
Stars: ✭ 366 (+771.43%)
Mutual labels:  image, palette, color
Colority
🎨 (~1kb) library to extract colors from pictures.
Stars: ✭ 74 (+76.19%)
Mutual labels:  extract, rgb, colors
global-color-picker
start the script and click anywhere to get rgb value at the cursor location
Stars: ✭ 31 (-26.19%)
Mutual labels:  color, colors, rgb
Color Names
Large list of handpicked color names 🌈
Stars: ✭ 1,198 (+2752.38%)
Mutual labels:  palette, color, colors
React Color Extractor
A React component which extracts colors from an image
Stars: ✭ 314 (+647.62%)
Mutual labels:  image, rgb, colors
Colorpicker
jQuery UI widget for color picking (similar to the one in Microsoft Office 2010).
Stars: ✭ 271 (+545.24%)
Mutual labels:  palette, color, colors
Lantern
基于Swiftηš„ι«˜ε―η”¨θ§†ε›Ύζ‘†ζžΆ
Stars: ✭ 181 (+330.95%)
Mutual labels:  image, photo, browser
Tui.image Editor
🍞🎨 Full-featured photo image editor using canvas. It is really easy, and it comes with great filters.
Stars: ✭ 4,761 (+11235.71%)
Mutual labels:  image, photo, canvas
Hxphotopicker
图片/视钑选择器 - ζ”―ζŒLivePhoto、GIF图片选择、3DTouchι’„θ§ˆγ€εœ¨ηΊΏδΈ‹θ½½iCloudδΈŠηš„θ΅„ζΊγ€ηΌ–θΎ‘ε›Ύη‰‡/θ§†ι’‘γ€ζ΅θ§ˆη½‘η»œε›Ύη‰‡ εŠŸθƒ½ Imitation wx photo/image picker - support for LivePhoto, GIF image selection, 3DTouch preview, Download the resources on iCloud online, browse the web image function
Stars: ✭ 2,363 (+5526.19%)
Mutual labels:  image, photo, browser
hcv-color
🌈 Color model HCV/HCG is an alternative to HSV and HSL, derived by Munsell color system, usable for Dark and Light themes... 🌈
Stars: ✭ 44 (+4.76%)
Mutual labels:  color, palette, rgb
Xcodecolorsense
🎈 An Xcode plugin that makes working with color easier
Stars: ✭ 79 (+88.1%)
Mutual labels:  palette, rgb, color
pantone-colors
Hex values of all 2310 Pantone colors
Stars: ✭ 147 (+250%)
Mutual labels:  color, palette, colors
Values.js
πŸ‡ Get the tints and shades of a color
Stars: ✭ 97 (+130.95%)
Mutual labels:  rgb, color, colors
Colorwaver
🎨 An app to detect color palettes in the real world - powered by VisionCamera
Stars: ✭ 365 (+769.05%)
Mutual labels:  color, palette, colors
React Image Magnify
A responsive image zoom component designed for shopping sites.
Stars: ✭ 391 (+830.95%)
Mutual labels:  image, photo, picture
Photobrowser
Elegant photo browser in Swift. ε›Ύη‰‡δΈŽθ§†ι’‘ζ΅θ§ˆε™¨γ€‚
Stars: ✭ 975 (+2221.43%)
Mutual labels:  image, photo, browser

color.js

Extract colors from an image. Works in the browser and in hybrid environments like Electron. Supports images that are present in the DOM, as well as (external) URL's. Size: ~0.75 KB (min + gzip).

Installation

npm install color.js

Or directly in the browser:

<script src="https://unpkg.com/[email protected]/dist/color.js"></script>

Usage example:

import { prominent } from 'color.js'

prominent('js-logo.jpg', { amount: 1 }).then(color => {
  console.log(color) // [241, 221, 63]
})

// Or with different syntax:

const color = await prominent('js-logo.jpg', { amount: 1 })
console.log(color) // [241, 221, 63]

When used directly in the browser:

<script src="https://unpkg.com/[email protected]/dist/color.js"></script>
colorjs.prominent('js-logo.jpg', { amount: 1 }).then(color => {
  console.log(color) // [241, 221, 63]
})

API

Prominent

Returns the most used color(s) in an image. Can be requested as a single color or palette of colors (see amount).

import { prominent } from 'color.js'

prominent('img.jpg').then(colors => ...)

Prominent

Average

Returns the average color of an image.

import { average } from 'color.js'

average('img.jpg').then(color => ...)

Average

Options

You can pass two arguments, an image and a configuration object.

Image (required)

Can be a URL or DOM element.

average('img.jpg')
const img = document.getElementById('photo')
average(img)
average('https://example.com/image.jpg')

When using an external image, CORS should of course be enabled on the source.

Configuration (optional)

Amount

Default: 3

Only applicable for prominent.

The amount of colors that should be returned. When set to 1 a singular value is returned, otherwise an array of values.

prominent('img.jpg', { amount: 5 })

Format

Default: 'array'

The format in which colors should be returned. Options are 'array' and 'hex'.

[241, 221, 63] // 'array'
'#f1dd3f' // 'hex'
average('img.jpg', { format: 'hex' })

Group

Default: 20

Configures how many similar colors should be combined into one color. A value of 1 would mean every individual color would be considered, but this is often not ideal. Especially in photographs there's usually a lot of color data, and grouping colors could give more usable results. In the first example below, group is set to 5 and a lot of individual colors in the sea are returned. When more grouping is applied (30 in the second example), the results become more distinct.

prominent('img.jpg', { group: 30 })

Group

Sample

Default: 10

Configures how many pixels of an image should be processed. For example, a value of 20 means every 20th pixel is interpreted. A higher value means less accurate results, but better performance. An example of default sampling on an image:

average('img.jpg', { sample: 10 })

Sample

Browser support

Pretty much everything (> 0.2%), except for IE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].