Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
optipng-bin
Advanced tools
OptiPNG wrapper that makes it seamlessly available as a local dependency
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.
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');
});
imagemin-optipng is a plugin for the imagemin image optimization tool that uses OptiPNG to compress PNG images. It offers similar functionality to optipng-bin but is designed to be used within the imagemin ecosystem, which supports multiple image formats and optimization plugins.
pngquant-bin is a Node.js wrapper for the pngquant command-line tool, which compresses PNG images using lossy compression. Unlike optipng-bin, which focuses on lossless compression, pngquant-bin can achieve smaller file sizes by allowing some quality loss.
pngcrush-bin is a Node.js wrapper for the pngcrush command-line tool, which optimizes PNG images by trying various compression methods and selecting the best one. It offers similar functionality to optipng-bin but uses a different optimization algorithm.
OptiPNG is a PNG optimizer that recompresses image files to a smaller size, without losing any information
You probably want imagemin-optipng
instead.
$ npm install --save optipng-bin
import {execFile} from 'node:child_process';
import optipng from 'optipng-bin';
execFile(optipng, ['-out', 'output.png', 'input.png'], error => {
console.log('Image minified!');
});
$ npm install --global optipng-bin
$ optipng --help
FAQs
OptiPNG wrapper that makes it seamlessly available as a local dependency
The npm package optipng-bin receives a total of 425,369 weekly downloads. As such, optipng-bin popularity was classified as popular.
We found that optipng-bin demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.