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.
pngquant-bin
Advanced tools
pngquant wrapper that makes it seamlessly available as a local dependency on OS X, Linux and Windows
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.
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`);
});
});
});
The imagemin-pngquant package is a plugin for Imagemin that uses pngquant to compress PNG images. It offers similar functionality to pngquant-bin but is designed to be used within the Imagemin ecosystem, which provides a more extensive set of image optimization tools.
The pngcrush-bin package provides a Node.js wrapper for the pngcrush command-line tool, which is another utility for optimizing PNG images. While pngcrush focuses on reducing file size by eliminating unnecessary data, it may not achieve the same level of compression as pngquant.
The optipng-bin package offers a Node.js wrapper for the OptiPNG command-line tool, which is used to optimize PNG images. OptiPNG performs lossless compression, meaning it reduces file size without affecting image quality, but it may not achieve the same compression ratios as pngquant.
pngquant 1.8.4 Node.js wrapper that makes it seamlessly available as a local dependency on OS X, Linux and Windows.
pngquant is a command-line utility for converting 24/32-bit PNG images to paletted (8-bit) PNGs. The conversion reduces file sizes significantly (often as much as 70%) and preserves full alpha transparency.
Install with npm: npm install --save pngquant-bin
var execFile = require('child_process').execFile;
var binPath = require('pngquant-bin').path;
execFile(binPath, ['input.png'], function() {
console.log('Image minified');
});
Can also be run directly from ./node_modules/.bin/pngquant
.
Note to self on how to update the binaries.
Run npm install
on a OS X 10.7 machine to build the binary.
Run npm install
to build the binary.
Download the Windows binary and put it in vendor/win/
.
Everything except binaries: MIT License • © Sindre Sorhus
gifsicle licensed under the GNU General Public License, Version 2.
FAQs
`pngquant` wrapper that makes it seamlessly available as a local dependency
We found that pngquant-bin demonstrated a healthy version release cadence and project activity because the last version was released less than 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.