Socket
Socket
Sign inDemoInstall

optipng-bin

Package Overview
Dependencies
Maintainers
7
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

optipng-bin

OptiPNG wrapper that makes it seamlessly available as a local dependency


Version published
Maintainers
7
Created

What is optipng-bin?

The optipng-bin package provides a Node.js wrapper for the OptiPNG image optimization tool. It allows you to optimize PNG images by reducing their file size without losing quality. This can be particularly useful for web developers looking to improve page load times by minimizing image sizes.

What are optipng-bin's main functionalities?

Optimize a single PNG image

This feature allows you to optimize a single PNG image using the highest optimization level (-o7). The code sample demonstrates how to use the optipng-bin package to optimize 'input.png' and log a message upon completion.

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

execFile(optipng, ['-o7', 'input.png'], (err) => {
  if (err) {
    throw err;
  }
  console.log('Image optimized');
});

Optimize multiple PNG images

This feature allows you to optimize multiple PNG images in a batch. The code sample demonstrates how to loop through an array of image filenames and optimize each one using the optipng-bin package.

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

const images = ['image1.png', 'image2.png', 'image3.png'];

images.forEach((image) => {
  execFile(optipng, ['-o7', image], (err) => {
    if (err) {
      throw err;
    }
    console.log(`${image} optimized`);
  });
});

Custom optimization level

This feature allows you to specify a custom optimization level for the PNG image. The code sample demonstrates how to use the optipng-bin package to optimize 'input.png' with an optimization level of 2.

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

execFile(optipng, ['-o2', 'input.png'], (err) => {
  if (err) {
    throw err;
  }
  console.log('Image optimized with custom level');
});

Other packages similar to optipng-bin

Keywords

FAQs

Package last updated on 09 Dec 2018

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc