{"library":"node-vibrant","title":"node-vibrant: Image Color Palette Extraction","description":"node-vibrant is a JavaScript library engineered for extracting prominent colors and generating a color palette from images. It effectively analyzes image data to produce a set of 'swatches,' including vibrant, muted, dark vibrant, light vibrant, dark muted, and light muted colors. The library is currently at stable version 4.0.4 and has resumed active development following a substantial four-year hiatus before the significant 4.0.0 release. Key features include comprehensive support for both Node.js and browser environments, a full rewrite in TypeScript since version 3.0.0-alpha.1, and a modern Promise-based API for handling asynchronous operations. This combination makes it a robust solution for applications requiring dynamic, type-safe color palette generation from images, integrating smoothly with contemporary JavaScript development workflows.","language":"javascript","status":"active","last_verified":"Sun Apr 19","install":{"commands":["npm install node-vibrant"],"cli":null},"imports":["import { Vibrant } from 'node-vibrant/node';","import { Vibrant } from 'node-vibrant/browser';","const Vibrant = require('node-vibrant');"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import { Vibrant } from 'node-vibrant/node'; // Or 'node-vibrant/browser' for browsers\n\nasync function extractColorsFromImage(imageUrl: string) {\n  try {\n    console.log(`Extracting colors from: ${imageUrl}`);\n    const palette = await Vibrant.from(imageUrl).getPalette();\n\n    console.log('Generated Color Palette:');\n    console.log('  Vibrant:', palette.Vibrant?.hex || 'N/A');\n    console.log('  Muted:', palette.Muted?.hex || 'N/A');\n    console.log('  Dark Vibrant:', palette.DarkVibrant?.hex || 'N/A');\n    console.log('  Light Vibrant:', palette.LightVibrant?.hex || 'N/A');\n    console.log('  Dark Muted:', palette.DarkMuted?.hex || 'N/A');\n    console.log('  Light Muted:', palette.LightMuted?.hex || 'N/A');\n\n    if (palette.Vibrant) {\n      console.log(`  Vibrant RGB: ${palette.Vibrant.rgb}`);\n      console.log(`  Vibrant Population: ${palette.Vibrant.population}`);\n    }\n  } catch (error) {\n    console.error('Failed to extract colors:', error);\n  }\n}\n\n// Example usage with a public image URL\n// For a local file in Node.js, replace 'imageUrl' with a local path like 'file:///path/to/image.jpg'\nconst exampleImageUrl = 'https://picsum.photos/id/1018/1000/600';\nextractColorsFromImage(exampleImageUrl);","lang":"typescript","description":"Demonstrates how to extract a color palette from an image URL using the Promise-based API in a Node.js environment, displaying the dominant color swatches.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}