You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

image-q

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

image-q

Image Quantization Library in **TypeScript** *(MIT Licensed)*

1.1.1
Source
npmnpm
Version published
Weekly downloads
1.4M
-0.54%
Maintainers
1
Weekly downloads
 
Created

What is image-q?

image-q is an advanced image quantization library for Node.js and the browser. It provides various algorithms for color quantization and dithering, allowing you to reduce the number of colors in an image while maintaining visual quality.

What are image-q's main functionalities?

Color Quantization

This feature allows you to reduce the number of colors in an image using various quantization algorithms. The code sample demonstrates how to load an image, create a quantizer instance, and quantize the image.

const { ImageQuantizer, Palette } = require('image-q');
const fs = require('fs');

// Load an image (example uses a buffer from a file)
const imageBuffer = fs.readFileSync('path/to/image.png');

// Create a quantizer instance
const quantizer = new ImageQuantizer();

// Quantize the image
quantizer.quantize(imageBuffer).then((result) => {
  // Save the quantized image
  fs.writeFileSync('path/to/quantized_image.png', result);
});

Dithering

This feature allows you to apply dithering to an image, which helps to reduce color banding and improve visual quality. The code sample demonstrates how to load an image, create a ditherer instance, and apply dithering to the image.

const { ImageDitherer } = require('image-q');
const fs = require('fs');

// Load an image (example uses a buffer from a file)
const imageBuffer = fs.readFileSync('path/to/image.png');

// Create a ditherer instance
const ditherer = new ImageDitherer();

// Apply dithering to the image
const ditheredImage = ditherer.dither(imageBuffer);

// Save the dithered image
fs.writeFileSync('path/to/dithered_image.png', ditheredImage);

Palette Extraction

This feature allows you to extract the color palette from an image. The code sample demonstrates how to load an image, create a palette instance, and extract the palette colors from the image.

const { Palette } = require('image-q');
const fs = require('fs');

// Load an image (example uses a buffer from a file)
const imageBuffer = fs.readFileSync('path/to/image.png');

// Create a palette instance
const palette = new Palette();

// Extract the palette from the image
palette.buildPalette(imageBuffer).then((paletteColors) => {
  console.log('Extracted Palette:', paletteColors);
});

Other packages similar to image-q

Keywords

image

FAQs

Package last updated on 28 Aug 2016

Did you know?

Socket

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.

Install

Related posts