- Source:
Node exported functions.
Examples
const path = require('path')
const { extractColors } = require('extract-colors')
const src = path.join(__dirname, './my-image.jpg')
extractColors(src)
.then(console.log)
.catch(console.log)
import { extractColorsFromImageData } from 'extract-colors'
const imageData = { data: [0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF] }
extractColorsFromImageData(imageData)
.then(console.log)
.catch(console.error)
Methods
(inner) extractColors(picture, optionsopt) → {Array.<Object>}
- Source:
Extract colors from a picture.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
picture |
String | Image | ImageData | Src, Image or ImageData |
|||||||||||||||||||||||||
options |
Object |
<optional> |
Optional data Properties
|
Returns:
- Type
- Array.<Object>
(inner) extractColorsFromImageData(imageData, optionsopt) → {Array.<Object>}
- Source:
Extract colors from an ImageData object.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
imageData |
ImageData | ||||||||||||||||||||||||||
options |
Object |
<optional> |
Optional data Properties
|
Returns:
- Type
- Array.<Object>
(inner) extractColorsFromSrc(src, optionsopt) → {Array.<Object>}
- Source:
Extract colors from a path. The image will be downloaded.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
src |
String | ||||||||||||||||||||||||||
options |
Object |
<optional> |
Optional data Properties
|
Returns:
- Type
- Array.<Object>
(inner) getImageData(image, pixels) → {ImageData}
- Source:
Extract ImageData from image. Reduce image to a pixel count.
Parameters:
Name | Type | Description |
---|---|---|
image |
Image | Source image |
pixels |
Number | Maximum number of pixels for process |
Returns:
- Type
- ImageData