Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
optipng-bin
Advanced tools
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.
$ npm install --save optipng-bin
var execFile = require('child_process').execFile;
var optipng = require('optipng-bin');
execFile(optipng, ['-out', 'output.png', 'input.png'], function (err) {
console.log('Image minified!');
});
$ npm install --global optipng-bin
$ optipng --help
MIT © imagemin
FAQs
OptiPNG wrapper that makes it seamlessly available as a local dependency
The npm package optipng-bin receives a total of 243,197 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.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.