Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jpegtran-bin

Package Overview
Dependencies
Maintainers
6
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jpegtran-bin - npm Package Compare versions

Comparing version 3.2.0 to 4.0.0

6

cli.js
#!/usr/bin/env node
'use strict';
var spawn = require('child_process').spawn;
var jpegtran = require('./');
const {spawn} = require('child_process');
const jpegtran = require('.');
var input = process.argv.slice(2);
const input = process.argv.slice(2);
spawn(jpegtran, input, {stdio: 'inherit'})
.on('exit', process.exit);
'use strict';
var path = require('path');
var BinWrapper = require('bin-wrapper');
var pkg = require('../package.json');
const path = require('path');
const BinWrapper = require('bin-wrapper');
const pkg = require('../package.json');
var url = 'https://raw.githubusercontent.com/imagemin/jpegtran-bin/v' + pkg.version + '/vendor/';
const url = `https://raw.githubusercontent.com/imagemin/jpegtran-bin/v${pkg.version}/vendor/`;
module.exports = new BinWrapper()
.src(url + 'macos/jpegtran', 'darwin')
.src(url + 'linux/x86/jpegtran', 'linux', 'x86')
.src(url + 'linux/x64/jpegtran', 'linux', 'x64')
.src(url + 'freebsd/x86/jpegtran', 'freebsd', 'x86')
.src(url + 'freebsd/x64/jpegtran', 'freebsd', 'x64')
.src(url + 'sunos/x86/jpegtran', 'sunos', 'x86')
.src(url + 'sunos/x64/jpegtran', 'sunos', 'x64')
.src(url + 'win/x86/jpegtran.exe', 'win32', 'x86')
.src(url + 'win/x64/jpegtran.exe', 'win32', 'x64')
.src(url + 'win/x86/libjpeg-62.dll', 'win32', 'x86')
.src(url + 'win/x64/libjpeg-62.dll', 'win32', 'x64')
.src(`${url}macos/jpegtran`, 'darwin')
.src(`${url}linux/x86/jpegtran`, 'linux', 'x86')
.src(`${url}linux/x64/jpegtran`, 'linux', 'x64')
.src(`${url}freebsd/x86/jpegtran`, 'freebsd', 'x86')
.src(`${url}freebsd/x64/jpegtran`, 'freebsd', 'x64')
.src(`${url}sunos/x86/jpegtran`, 'sunos', 'x86')
.src(`${url}sunos/x64/jpegtran`, 'sunos', 'x64')
.src(`${url}win/x86/jpegtran.exe`, 'win32', 'x86')
.src(`${url}win/x64/jpegtran.exe`, 'win32', 'x64')
.src(`${url}win/x86/libjpeg-62.dll`, 'win32', 'x86')
.src(`${url}win/x64/libjpeg-62.dll`, 'win32', 'x64')
.dest(path.join(__dirname, '../vendor'))
.use(process.platform === 'win32' ? 'jpegtran.exe' : 'jpegtran');
'use strict';
var path = require('path');
var BinBuild = require('bin-build');
var log = require('logalot');
var bin = require('./');
const path = require('path');
const binBuild = require('bin-build');
const log = require('logalot');
const bin = require('.');
var args = [
'-copy', 'none',
const args = [
'-copy',
'none',
'-optimize',
'-outfile', path.join(__dirname, '../test/fixtures/test-optimized.jpg'),
'-outfile',
path.join(__dirname, '../test/fixtures/test-optimized.jpg'),
path.join(__dirname, '../test/fixtures/test.jpg')
];
bin.run(args, function (err) {
if (err) {
log.warn(err.message);
log.warn('jpegtran pre-build test failed');
log.info('compiling from source');
bin.run(args).then(() => {
log.success('jpegtran pre-build test passed successfully');
}).catch(error => {
log.warn(error.message);
log.warn('jpegtran pre-build test failed');
log.info('compiling from source');
var cfg = [
'./configure --disable-shared',
'--prefix="' + bin.dest() + '" --bindir="' + bin.dest() + '"'
].join(' ');
const cfg = [
'./configure --disable-shared',
`--prefix="${bin.dest()}" --bindir="${bin.dest()}"`
].join(' ');
var builder = new BinBuild()
.cmd('touch configure.ac aclocal.m4 configure Makefile.am Makefile.in')
.src('https://downloads.sourceforge.net/project/libjpeg-turbo/1.5.1/libjpeg-turbo-1.5.1.tar.gz')
.cmd(cfg)
.cmd('make install');
return builder.run(function (err) {
if (err) {
log.error(err.stack);
return;
}
log.success('jpegtran built successfully');
});
}
log.success('jpegtran pre-build test passed successfully');
binBuild.url('https://downloads.sourceforge.net/project/libjpeg-turbo/1.5.1/libjpeg-turbo-1.5.1.tar.gz', [
'touch configure.ac aclocal.m4 configure Makefile.am Makefile.in',
cfg,
'make install'
]).then(() => {
log.success('jpegtran built successfully');
}).catch(error => {
log.error(error.stack);
});
});
{
"name": "jpegtran-bin",
"version": "3.2.0",
"version": "4.0.0",
"description": "jpegtran (part of libjpeg-turbo) bin-wrapper that makes it seamlessly available as a local dependency",

@@ -23,11 +23,11 @@ "license": "MIT",

],
"engines": {
"node": ">=0.10.0"
},
"bin": {
"jpegtran": "cli.js"
},
"engines": {
"node": ">=6"
},
"scripts": {
"postinstall": "node lib/install.js",
"test": "xo && mocha --timeout 100000"
"test": "xo && ava"
},

@@ -41,2 +41,3 @@ "files": [

"keywords": [
"imagemin",
"compress",

@@ -48,17 +49,18 @@ "image",

"minify",
"optimize"
"optimize",
"jpegtran"
],
"dependencies": {
"bin-build": "^2.0.0",
"bin-wrapper": "^3.0.0",
"bin-build": "^3.0.0",
"bin-wrapper": "^4.0.0",
"logalot": "^2.0.0"
},
"devDependencies": {
"bin-check": "^3.0.0",
"compare-size": "^1.0.1",
"mkdirp": "^0.5.0",
"mocha": "^2.2.4",
"rimraf": "^2.3.2",
"ava": "*",
"bin-check": "^4.0.1",
"compare-size": "^3.0.0",
"execa": "^1.0.0",
"tempy": "^0.2.1",
"xo": "*"
}
}
# jpegtran-bin [![Build Status](https://travis-ci.org/imagemin/jpegtran-bin.svg?branch=master)](https://travis-ci.org/imagemin/jpegtran-bin)
> 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.
> [libjpeg-turbo](http://libjpeg-turbo.virtualgl.org/) 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.
You probably want [`imagemin-jpegtran`](https://github.com/imagemin/imagemin-jpegtran) instead.
## Install

@@ -38,2 +40,2 @@

MIT © [imagemin](https://github.com/imagemin)
MIT © [Imagemin](https://github.com/imagemin)
'use strict';
/* eslint-env mocha */
var assert = require('assert');
var execFile = require('child_process').execFile;
var fs = require('fs');
var path = require('path');
var BinBuild = require('bin-build');
var binCheck = require('bin-check');
var compareSize = require('compare-size');
var mkdirp = require('mkdirp');
var rimraf = require('rimraf');
const fs = require('fs');
const path = require('path');
const test = require('ava');
const execa = require('execa');
const tempy = require('tempy');
const binCheck = require('bin-check');
const binBuild = require('bin-build');
const compareSize = require('compare-size');
const jpegtran = require('..');
var tmp = path.join(__dirname, 'tmp');
beforeEach(function () {
mkdirp.sync(tmp);
});
afterEach(function () {
rimraf.sync(tmp);
});
it('rebuild the jpegtran binaries', function (cb) {
var cfg = [
test('rebuild the jpegtran binaries', async t => {
const tmp = tempy.directory();
const cfg = [
'./configure --disable-shared',
'--prefix="' + tmp + '" --bindir="' + tmp + '"'
`--prefix="${tmp}" --bindir="${tmp}"`
].join(' ');
new BinBuild()
.src('https://downloads.sourceforge.net/project/libjpeg-turbo/1.5.1/libjpeg-turbo-1.5.1.tar.gz')
.cmd(cfg)
.cmd('make install')
.run(function (err) {
if (err) {
cb(err);
return;
}
await binBuild.url('https://downloads.sourceforge.net/project/libjpeg-turbo/1.5.1/libjpeg-turbo-1.5.1.tar.gz', [
cfg,
'make install'
]);
assert(fs.statSync(path.join(tmp, 'jpegtran')).isFile());
cb();
});
t.true(fs.existsSync(path.join(tmp, 'jpegtran')));
});
it('return path to binary and verify that it is working', function () {
var args = [
'-outfile', path.join(tmp, 'test.jpg'),
path.join(__dirname, 'fixtures/test.jpg')
];
return binCheck(require('../'), args).then(assert);
test('return path to binary and verify that it is working', async t => {
t.true(await binCheck(jpegtran, ['-version']));
});
it('minify a JPG', function (cb) {
var src = path.join(__dirname, 'fixtures/test.jpg');
var dest = path.join(tmp, 'test.jpg');
var args = [
'-outfile', dest,
test('minify a JPG', async t => {
const tmp = tempy.directory();
const src = path.join(__dirname, 'fixtures/test.jpg');
const dest = path.join(tmp, 'test.jpg');
const args = [
'-outfile',
dest,
src
];
execFile(require('../'), args, function (err) {
if (err) {
cb(err);
return;
}
await execa(jpegtran, args);
const res = await compareSize(src, dest);
compareSize(src, dest, function (err, res) {
if (err) {
cb(err);
return;
}
assert(res[dest] < res[src]);
cb();
});
});
t.true(res[dest] < res[src]);
});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc