Socket
Socket
Sign inDemoInstall

pngquant-bin

Package Overview
Dependencies
4
Maintainers
5
Versions
36
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    pngquant-bin

`pngquant` wrapper that makes it seamlessly available as a local dependency


Version published
Maintainers
5
Created

Package description

What is pngquant-bin?

The pngquant-bin npm package provides a Node.js wrapper for the pngquant command-line tool, which is used to compress PNG images. It allows developers to reduce the file size of PNG images while maintaining a balance between quality and compression.

What are pngquant-bin's main functionalities?

Compress PNG images

This feature allows you to compress PNG images by specifying the quality range. The code sample demonstrates how to use the pngquant-bin package to compress an image named 'input.png' and save the compressed version as 'output.png'.

const pngquant = require('pngquant-bin');
const { execFile } = require('child_process');

execFile(pngquant, ['--quality=65-80', 'input.png', '-o', 'output.png'], err => {
  if (err) {
    throw err;
  }
  console.log('Image compressed successfully');
});

Batch processing of PNG images

This feature allows you to compress multiple PNG images in a directory. The code sample demonstrates how to read all files in the 'images' directory, compress each one, and save the compressed versions in the 'compressed_images' directory.

const pngquant = require('pngquant-bin');
const { execFile } = require('child_process');
const fs = require('fs');
const path = require('path');

const inputDir = 'images';
const outputDir = 'compressed_images';

fs.readdir(inputDir, (err, files) => {
  if (err) {
    throw err;
  }
  files.forEach(file => {
    const inputFile = path.join(inputDir, file);
    const outputFile = path.join(outputDir, file);
    execFile(pngquant, ['--quality=65-80', inputFile, '-o', outputFile], err => {
      if (err) {
        throw err;
      }
      console.log(`${file} compressed successfully`);
    });
  });
});

Other packages similar to pngquant-bin

Readme

Source

pngquant-bin Build Status

pngquant is a PNG compressor that significantly reduces file sizes by converting images to a more efficient 8-bit PNG format

You probably want imagemin-pngquant instead.

Install

$ npm install pngquant-bin

Usage

const execFile = require('child_process').execFile;
const pngquant = require('pngquant-bin');

execFile(pngquant, ['-o', 'output.png', 'input.png'], err => {
	console.log('Image minified!');
});

CLI

$ npm install --global pngquant-bin
$ pngquant --help

License

MIT © Imagemin

Keywords

FAQs

Last updated on 15 Mar 2018

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc