|
1 | 1 | /// <reference lib="dom" /> |
| 2 | +/// <reference types="node" /> |
2 | 3 |
|
3 | 4 | export = ColorThief; |
4 | 5 | export as namespace ColorThief; |
@@ -41,6 +42,38 @@ declare namespace ColorThief { |
41 | 42 | * Color Thief - Extract dominant colors from images |
42 | 43 | */ |
43 | 44 | declare class ColorThief { |
| 45 | + // -------------------------------------------------------- |
| 46 | + // Node.js usage (Static methods returning Promises) |
| 47 | + // -------------------------------------------------------- |
| 48 | + |
| 49 | + /** |
| 50 | + * Extract the dominant color from an image (Node.js) |
| 51 | + * @param sourceImage - Path to the image file, or Buffer containing image |
| 52 | + * @param quality - Quality/speed trade-off (1 = highest quality, 10 = default) |
| 53 | + * @returns Promise resolving to RGB color array [r, g, b] where values are 0-255 |
| 54 | + */ |
| 55 | + static getColor( |
| 56 | + sourceImage: Buffer | Uint8Array | ArrayBuffer | string, |
| 57 | + quality?: number, |
| 58 | + ): Promise<ColorThief.RGBColor>; |
| 59 | + |
| 60 | + /** |
| 61 | + * Extract a palette of colors from an image (Node.js) |
| 62 | + * @param sourceImage - Path to the image file, or Buffer containing image |
| 63 | + * @param colorCount - Number of colors to extract (2-20, default: 10) |
| 64 | + * @param quality - Quality/speed trade-off (1 = highest quality, 10 = default) |
| 65 | + * @returns Promise resolving to Array of RGB color arrays [[r, g, b], ...] where values are 0-255 |
| 66 | + */ |
| 67 | + static getPalette( |
| 68 | + sourceImage: Buffer | Uint8Array | ArrayBuffer | string, |
| 69 | + colorCount?: number, |
| 70 | + quality?: number, |
| 71 | + ): Promise<ColorThief.RGBColor[]>; |
| 72 | + |
| 73 | + // -------------------------------------------------------- |
| 74 | + // Browser usage (Instance methods) |
| 75 | + // -------------------------------------------------------- |
| 76 | + |
44 | 77 | /** |
45 | 78 | * Extract the dominant color from an image |
46 | 79 | * @param sourceImage - HTML image element |
|
0 commit comments