
Security News
Deno Goes the Way of the Dinosaur
Cloudflare is acquiring Deno’s team, which will provide another year of bug fixes and security updates before ending support for the runtime.
libimagequant-wasm
Advanced tools
WASM bindings for libimagequant image quantization library with Web Worker support
A TypeScript/JavaScript WebAssembly wrapper for the libimagequant image quantization library. This package provides high-quality image color quantization in the browser using Web Workers for optimal performance.
npm install libimagequant-wasm
npm install
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
rustup target add wasm32-unknown-unknown
npm run build
This will:
import LibImageQuant, { QuantizationOptions } from 'libimagequant-wasm';
// Create quantizer instance
const quantizer = new LibImageQuant();
// Quantize an image from canvas
const canvas = document.getElementById('myCanvas') as HTMLCanvasElement;
const options: QuantizationOptions = {
maxColors: 64,
quality: { min: 70, target: 100 },
speed: 3
};
const result = await quantizer.quantizeCanvas(canvas, options);
console.log(`Quantized to ${result.paletteLength} colors`);
console.log(`Quality: ${Math.round(result.quality * 100)}%`);
// Apply result to another canvas
const outputCanvas = document.getElementById('outputCanvas') as HTMLCanvasElement;
quantizer.applyToCanvas(outputCanvas, result);
// Clean up
quantizer.dispose();
import { quantizeCanvas, quantizeImage } from 'libimagequant-wasm';
// One-shot quantization (automatically handles worker lifecycle)
const result = await quantizeCanvas(canvas, { maxColors: 128 });
// Quantize from image element
const img = document.getElementById('myImage');
const result = await quantizeImage(img, {
maxColors: 64,
dithering: 0.8
});
import LibImageQuant from 'libimagequant-wasm';
const quantizer = new LibImageQuant();
// Get ImageData from canvas
const ctx = canvas.getContext('2d');
const imageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
// Quantize
const result = await quantizer.quantizeImageData(imageData, {
maxColors: 32,
speed: 1, // Slower but higher quality
quality: { min: 80, target: 100 }
});
// Convert back to ImageData
const quantizedImageData = quantizer.toImageData(result);
ctx.putImageData(quantizedImageData, 0, 0);
quantizer.dispose();
const quantizer = new LibImageQuant(options)
Options:
workerUrl (string): Custom path to worker.js filequantizeCanvas(canvas, options)
quantizeImage(image, options)
quantizeImageData(imageData, options)
applyToCanvas(canvas, result)
toImageData(result)
dispose()
const options = {
maxColors: 256, // Maximum colors in palette (2-256)
speed: 3, // Speed vs quality (1-10, lower = better quality)
quality: { // Quality settings
min: 0, // Minimum quality (0-100)
target: 100 // Target quality (0-100)
},
dithering: 1.0, // Dithering level (0.0-1.0)
posterization: 0 // Posterization level (0-4)
};
{
palette: [[r, g, b, a], ...], // Color palette array
indexedData: [index, ...], // Palette indices for each pixel
imageData: [r, g, b, a, ...], // RGBA data (if returnRgba !== false)
quality: 0.95, // Achieved quality (0-1)
paletteLength: 64, // Number of colors in palette
width: 400, // Image width
height: 300 // Image height
}
Requires WebAssembly and Web Worker support.
See test.html for a complete working example with:
MIT License - See LICENSE file for details.
Important Note: This project wraps the libimagequant library, which is dual-licensed under GPL-3.0 and commercial licenses. While this wrapper is MIT licensed, you must ensure you comply with the appropriate libimagequant license for your use case. For commercial use, you may need to obtain a commercial license from the libimagequant authors.
npm testEnsure worker.js is served from the same origin or configure CORS headers.
typeof WebAssembly === 'object'FAQs
WASM bindings for libimagequant image quantization library with Web Worker support
The npm package libimagequant-wasm receives a total of 0 weekly downloads. As such, libimagequant-wasm popularity was classified as not popular.
We found that libimagequant-wasm 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.

Security News
Cloudflare is acquiring Deno’s team, which will provide another year of bug fixes and security updates before ending support for the runtime.

Security News
Anthropic’s free OSS Scanner uses Mythos and other Claude models to find open source vulnerabilities and send maintainers reports with proposed fixes.

Security News
On Front Lines’ Early Adopters: CISO podcast, Andrew Becherer shares lessons from Datadog, weighs the long-term costs of AI-built tools, and explains how founders can actually gain a CISO’s trust.