Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pngquant-bin

Package Overview
Dependencies
Maintainers
7
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pngquant-bin

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

  • 6.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
329K
decreased by-22.78%
Maintainers
7
Weekly downloads
 
Created

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

Keywords

FAQs

Package last updated on 01 Jun 2020

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