1.1.1 • Published 1 year ago

@babidi/pix v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@babidi/pix

A library to process images and extract dominant color and palette.

Installation

You can install the library via npm or yarn:

npm install @babidi/pix

or

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:

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.dominantHex); // Dominant color in hexadecimal format
console.log('Palette:', image.paletteHex); // Array of colors in hexadecimal format

Replace 'path_to_your_image.jpg' with the path to the image file you want to process.

API Documentation

Pix

Constructor

new Pix(buffer: Buffer, filetype: Pix.Format): Pix

Creates a new Pix object with the provided image data and file format.

Properties

  • dominant: Color
    • The dominant color of the image.
  • dominantHex: string
    • The dominant color of the image in hexadecimal format.
  • palette: Color[]
    • The color palette of the image.
  • paletteHex: string[]
    • The color palette of the image in hexadecimal format.

Enums

Pix.Format

An enum representing supported image formats:

  • JPEG
  • JPG
  • PNG
  • GIF
  • BMP
  • WEBP

License

This project is licensed under the MIT License - see the LICENSE file for details.

For bug reporting and feature requests, please use the issues section of the repository.

1.1.1

1 year ago

1.1.0

1 year ago

1.0.7

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.0

1 year ago