4.0.5 • Published 1 year ago

@types/get-image-colors v4.0.5

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

Installation

npm install --save @types/get-image-colors

Summary

This package contains type definitions for get-image-colors (https://github.com/colorjs/get-image-colors#readme).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/get-image-colors.

index.d.ts

// Type definitions for get-image-colors 4.0
// Project: https://github.com/colorjs/get-image-colors#readme
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped

/// <reference types="node" />

import { Color } from 'chroma-js';

/**
 * Extract colors from images. Supports GIF, JPG, PNG, and even SVG!
 */
declare function colorPalette(input: Buffer, options: colorPalette.Options, callback: Color[]): void;
declare function colorPalette(input: Buffer, type: string, callback: colorPalette.Callback): void;
declare function colorPalette(input: Buffer, type: string): Promise<Color[]>;
declare function colorPalette(input: string, options?: colorPalette.Options): Promise<Color[]>;
declare function colorPalette(input: string, callback: colorPalette.Callback): void;

declare namespace colorPalette {
    interface Options {
        /**
         * @default undefined
         */
        type?: string | undefined;
        /**
         * @default 5
         */
        count?: number | undefined;
    }

    /**
     * If you don't like promises, you can use node-style callbacks too
     */
    type Callback = (error: Error | null, colors: Color[]) => void;
}

export = colorPalette;

Additional Details

Credits

These definitions were written by Piotr Błażejewicz.