Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
PNG optimizer, similar to OptiPNG
jspngopt
is a tool which tries to reduce the file size of a PNG file by
This is very similar to the OptiPNG tool. However, there is no shared code, and this implementation is written completely in JavaScript. It will usually make use of the zlib bindings provided by node.js, making use of the performance of native code there. But it is also possible to use pako or similar libraries to provide a portable all-JavaScript setup. Using a fixed version of pako on node.js will ensure reproducible results, but may result in slightly larger files compared to the latest native zlib.
On node.js, simply do
npm install jspngopt
A version which supports browserify is planned. If you need things packaged for some other environment, please file a ticket explaining your setup.
The command line interface of jspngopt
is intended to be
mostly compatible with the one from optipng
.
But as this project is in the early stages of development,
currently the only thing accepted on the command line is a list of file names,
which will be optimized with the default settings,
the results overwriting the input files if there was a size reduction.
The central element of the API is the Optimizer
object.
var jspngopt = require("jspngopt");
var opt = new jspngopt.Optimizer();
var optimized = opt.bufferSync(unoptimized);
The Optimizer
constructor takes an options
dictionary.
It may contain the following elements:
optipng
.pako
module, as returned from require("pako")
.
Setting this option will use pako
instead of zlib
,
ensuring reproducible results but possibly sacrificing performance
and compression rate.zlib.deflateSync
and which should be used in its stead.IDAT
chunk, defaults to 0x7fffffff
.
This is the length of the raw data payload, excluding header and checksum.verbosity
> 0).
Defaults to console.log
.Each parameter combination is described by the following numbers:
filters: Which filters to try. Numbers 0 through 4 correspond to the
filters None through Paeth described in the PNG specification.
Filter 5 corresponds to an adaptive choice of filters which minimizes
the sum of the absolute values in each row.
Default: [0, 5]
.
interlace: 0 disables interlacing, while 1 will eventually enable
Adam7 interlacing. Right now interlacing is not supported yet.
Default: [0]
.
windowBits: Base-two logarithm of the size of the sliding window
used to find redundant data.
Valid values are in the range from 8 through 15.
Default: [15]
.
level: Compression level, in the range from 0 (no compression)
to 9 (best compression).
Default: [9]
.
memLevel: Memory usage level, from 1 (little memory) to 9 (large memory).
Default: [8, 9]
.
strategy: Compression strategy.
DEFAULT_STRATEGY
used for generic data.FILTERED
, optimized for the fact that numbers are likely small.HUFFMANN_ONLY
to not match duplicates at all.RLE
, performing only run-length encoding.FIXED
uses a fixed Huffmann coding table.Default: [0, 1, 2, 3]
.
Takes the content of a complete PNG file as input, and returns an optimized version on output. Will throw an exception in case of an error.
Takes the name of a PNG file which will be read, optimized and written to the same location. Will throw an exception in case of an error. This method is not available in the browserified version.
FAQs
PNG optimizer, similar to optipng
The npm package jspngopt receives a total of 22 weekly downloads. As such, jspngopt popularity was classified as not popular.
We found that jspngopt demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.