Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
pngquant-bin
Advanced tools
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 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.
$ npm install --save pngquant-bin
var execFile = require('child_process').execFile;
var pngquant = require('pngquant-bin').path;
execFile(pngquant, ['-o', 'output.png', 'input.png'], function (err) {
if (err) {
throw err;
}
console.log('Image minified!');
});
$ npm install --global pngquant-bin
$ pngquant --help
MIT © imagemin
FAQs
`pngquant` wrapper that makes it seamlessly available as a local dependency
The npm package pngquant-bin receives a total of 344,246 weekly downloads. As such, pngquant-bin popularity was classified as popular.
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
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
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.