
Research
Supply Chain Attack on Axios Pulls Malicious Dependency from npm
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.
@ltcode/color-extractor
Advanced tools
Extract dominant colors from images easily with JavaScript/TypeScript.
Extract dominant colors from images easily using JavaScript/TypeScript. Compatible with Node.js and Browsers!
npm install @ltcode/color-extractor
import { extractColors } from '@ltcode/color-extractor';
// Extract 5 dominant colors in hexadecimal format
const colors = await extractColors('path/to/image.jpg');
console.log(colors); // ['#ff8040', '#2a5d84', '#f4e8d0', ...]
import { extractColors } from '@ltcode/color-extractor';
// File upload
const fileInput = document.querySelector('input[type="file"]');
fileInput.addEventListener('change', async (e) => {
const file = e.target.files[0];
const colors = await extractColors(file);
console.log(colors);
});
// HTML image element
const img = document.querySelector('img');
const colors = await extractColors(img);
// Canvas
const canvas = document.querySelector('canvas');
const colors = await extractColors(canvas);
// Image URL (with CORS)
const colors = await extractColors('https://example.com/image.jpg');
import { extractColors, extractDominantColor } from '@ltcode/color-extractor';
// Extract only the dominant color
const dominantColor = await extractDominantColor('image.jpg');
// Custom options
const colors = await extractColors('image.jpg', {
maxColors: 8, // Maximum number of colors (default: 5)
quality: 5, // Analysis quality (default: 10)
format: 'rgb', // Format: 'hex', 'rgb', 'hsl'
ignoreLightColors: true, // Ignore light colors
ignoreDarkColors: false // Ignore dark colors
});
import fs from 'fs/promises';
import { extractColors } from '@ltcode/color-extractor';
const imageBuffer = await fs.readFile('image.jpg');
const colors = await extractColors(imageBuffer);
const dropZone = document.getElementById('dropZone');
dropZone.addEventListener('drop', async (e) => {
e.preventDefault();
const files = e.dataTransfer.files;
if (files.length > 0) {
const colors = await extractColors(files[0]);
displayColors(colors);
}
});
extractColors(input, options?)string (file path) | Bufferstring (URL) | File | HTMLImageElement | HTMLCanvasElement | ImageDataColorExtractionOptions - Configuration optionsPromise<ColorResult[]> - Array of colorsextractDominantColor(input, options?)extractColorsColorExtractionOptions - Configuration optionsPromise<ColorResult | null> - Dominant colorextractPalette(input, options?)Alias for extractColors - extracts complete color palette.
ColorExtractionOptions){
maxColors?: number; // Maximum colors (default: 5)
quality?: number; // Quality 1-50 (default: 10)
format?: 'hex'|'rgb'|'hsl'; // Output format (default: 'hex')
ignoreLightColors?: boolean; // Ignore light colors
ignoreDarkColors?: boolean; // Ignore dark colors
}
Check out the interactive demo to test in your browser!
See more examples in the GitHub repository
MIT
FAQs
Extract dominant colors from images easily with JavaScript/TypeScript.
We found that @ltcode/color-extractor demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.