Optimizes the compression using ML based metrics in a trial ’n error sorta manner.
This is a tool that can competitively optimize (e.g.) extremely noisy, high resolution images; at the expense of increased encoding time and CPU overhead. This is a tradeoff that should be suitable for over 90% of online content, where site performance matters.
It's pretty easy too.
$ npm install --save imager-io
Using the JavaScript non-blocking API:
const {ImageBuffer} = require("imager-io");
ImageBuffer
.open("source-image.jpeg")
.then(buffer => buffer.opt())
.then(buffer => buffer.save("result.jpeg"))
.then(() => console.log("done"));
source : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 39.00M (4 images)
kraken.io : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 24M
jpegmini.com : ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 16M
compression.ai: ▇▇▇▇▇▇▇▇ 8.90M
imager : ▇▇▇▇ 4.20M
Format | Decoding |
---|---|
PNG | All supported color types |
JPEG | Baseline and progressive |
GIF | Yes |
BMP | Yes |
ICO | Yes |
TIFF | Baseline(no fax support) + LZW + PackBits |
WebP | Lossy(Luma channel only) |
PNM | PBM, PGM, PPM, standard PAM |
Essentially supports any image decodable by image-rs.
These are your optimization targets (for lack of a better name). It’s a bit higher level, since e.g. rate control is automatically handled.
Format | Encoding |
---|---|
JPEG | progressive |
OS | Current Status |
---|---|
Linux | ✅ [GOOD] |
MacOS | ✅ [GOOD] |
Windows | ❌ [UNPRIORITIZED] (Use WSL) |
It’s possible and pretty easy to use Webpack and Imager already, here is an example.
Just use the GitHub issue tracker for this project.
Our npm releases contain prebuilt native node libraries (i.e. the rust code). With eventual plans for WASM support.
Copyright 2019 Colbyn Wadman