Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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)*

  • 4.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
327K
decreased by-64.53%
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

FAQs

Package last updated on 08 Jan 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc