jpegtran 1.3 (part of libjpeg-turbo) Node.js wrapper that makes it seamlessly available as a local dependency on OS X, Linux, FreeBSD, Solaris and Windows. Most commonly used to losslessly minify JPEG images.
libjpeg-turbo is a derivative of libjpeg that uses SIMD instructions (MMX, SSE2, NEON) to accelerate baseline JPEG compression and decompression on x86, x86-64, and ARM systems. On such systems, libjpeg-turbo is generally 2-4x as fast as the unmodified version of libjpeg, all else being equal.
Install with npm: npm install --save jpegtran-bin
var execFile = require('child_process').execFile;
var jpegtranPath = require('jpegtran-bin').path;
execFile(jpegtranPath, ['-outfile', 'output.jpg', 'input.jpg'], function() {
console.log('Image minified');
});
Can also be run directly from ./node_modules/.bin/jpegtran
.
Note to self on how to update the binaries.
Run npm install
to build the binary.
- Download the Windows files 32/64-bit (GCC compiled) on a Windows machine
- Run the downloaded file to extract
- Go to the
bin
folder at the destination and copyjpegtran.exe
andlibjpeg-62.dll
Everything excluding the binaries licensed under the BSD license and copyright Google.
libjpeg-turbo licensed under the BSD license and copyright dcommander.