https://github.com/valentin-marquez/pix
🎨 Pix is a Node.js library for extracting dominant colors from images.
https://github.com/valentin-marquez/pix
color-palette image-processing predominant-colors
Last synced: about 7 hours ago
JSON representation
🎨 Pix is a Node.js library for extracting dominant colors from images.
- Host: GitHub
- URL: https://github.com/valentin-marquez/pix
- Owner: valentin-marquez
- License: mit
- Created: 2024-02-11T01:55:51.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-04T00:17:15.000Z (almost 2 years ago)
- Last Synced: 2025-08-25T22:42:41.890Z (10 months ago)
- Topics: color-palette, image-processing, predominant-colors
- Language: TypeScript
- Homepage:
- Size: 53.8 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# @babidi/pix
A library to process images and extract dominant color and palette.
## Installation
You can install the library via npm or yarn:
```bash
npm install @babidi/pix
```
or
```bash
yarn add @babidi/pix
```
## Usage
Here's an example of how you can use `@babidi/pix` to extract the predominant color and palette from an image:
```javascript
import Pix from '@babidi/pix';
import * as fs from 'fs';
const imageBuffer = fs.promises.readFile('path_to_your_image.jpg');
const image = new Pix(imageBuffer, Pix.Format.JPG);
console.log('Dominant Color:', image.dominant.toHex());
console.log('Palette:', image.palette.toHex());
```
Replace `'path_to_your_image.jpg'` with the path to the image file you want to process.
## Benchmark
A benchmark was conducted comparing the performance of `@babidi/pix` with another popular library called ColorThief in extracting the dominant color and color palette from different types of image files. Times are shown in milliseconds (ms).
| File Type | Pix (ms) | ColorThief (ms) |
|-----------|----------|-----------------|
| PNG | 274 | 2325 |
| JPEG | 309 | 3781 |
| GIF | 262 | 237 |
| BMP | 122 | No Supported |
| WEBP | 726 | No Supported |
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
For bug reporting and feature requests, please use the [issues](https://github.com/valentin-marquez/pix/issues) section of the repository.