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

jpegtran-bin

Package Overview
Dependencies
Maintainers
7
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 0.2.6 to 0.2.7

test/fixtures/test-optimized.jpg

83

index.js
'use strict';
var BinBuild = require('bin-build');
var BinWrapper = require('bin-wrapper');

@@ -12,11 +13,15 @@ var chalk = require('chalk');

var bin = new BinWrapper({ bin: 'jpegtran', dest: path.join(__dirname, 'vendor') });
var bs = './configure --disable-shared ' +
'--prefix="' + bin.dest + '" && ' + 'make install';
var args = [
'-copy', 'none',
'-optimize',
'-outfile', path.join(__dirname, 'test/tmp/test.jpg'),
path.join(__dirname, 'test/fixtures/test.jpg')
];
var bin = new BinWrapper()
.src('https://raw.github.com/imagemin/jpegtran-bin/0.2.7/vendor/osx/jpegtran', 'darwin')
.src('https://raw.github.com/imagemin/jpegtran-bin/0.2.7/vendor/linux/x86/jpegtran', 'linux', 'x86')
.src('https://raw.github.com/imagemin/jpegtran-bin/0.2.7/vendor/linux/x64/jpegtran', 'linux', 'x64')
.src('https://raw.github.com/imagemin/jpegtran-bin/0.2.7/vendor/freebsd/jpegtran', 'freebsd')
.src('https://raw.github.com/imagemin/jpegtran-bin/0.2.7/vendor/sunos/x86/jpegtran', 'sunos', 'x86')
.src('https://raw.github.com/imagemin/jpegtran-bin/0.2.7/vendor/sunos/x64/jpegtran', 'sunos', 'x64')
.src('https://raw.github.com/imagemin/jpegtran-bin/0.2.7/vendor/win/x86/jpegtran.exe', 'win32', 'x86')
.src('https://raw.github.com/imagemin/jpegtran-bin/0.2.7/vendor/win/x64/jpegtran.exe', 'win32', 'x64')
.src('https://raw.github.com/imagemin/jpegtran-bin/0.2.7/vendor/win/x86/libjpeg-62.dll', 'win32', 'x86')
.src('https://raw.github.com/imagemin/jpegtran-bin/0.2.7/vendor/win/x64/libjpeg-62.dll', 'win32', 'x64')
.dest(path.join(__dirname, 'vendor'))
.use(process.platform === 'win32' ? 'jpegtran.exe' : 'jpegtran');

@@ -27,39 +32,31 @@ /**

fs.exists(bin.path, function (exists) {
fs.exists(bin.use(), function (exists) {
if (!exists) {
if (!fs.existsSync(path.join(__dirname, 'test/tmp'))) {
fs.mkdirSync(path.join(__dirname, 'test/tmp'));
}
var args = [
'-copy', 'none',
'-optimize',
'-outfile', path.join(__dirname, 'test/fixtures/test-optimized.jpg'),
path.join(__dirname, 'test/fixtures/test.jpg')
];
bin
.addUrl('https://raw.github.com/yeoman/node-jpegtran-bin/0.2.4/vendor/osx/jpegtran', 'darwin')
.addUrl('https://raw.github.com/yeoman/node-jpegtran-bin/0.2.4/vendor/linux/x86/jpegtran', 'linux', 'x86')
.addUrl('https://raw.github.com/yeoman/node-jpegtran-bin/0.2.4/vendor/linux/x64/jpegtran', 'linux', 'x64')
.addUrl('https://raw.github.com/yeoman/node-jpegtran-bin/0.2.4/vendor/freebsd/jpegtran', 'freebsd')
.addUrl('https://raw.github.com/yeoman/node-jpegtran-bin/0.2.4/vendor/sunos/x86/jpegtran', 'sunos', 'x86')
.addUrl('https://raw.github.com/yeoman/node-jpegtran-bin/0.2.4/vendor/sunos/x64/jpegtran', 'sunos', 'x64')
.addUrl('https://raw.github.com/yeoman/node-jpegtran-bin/0.2.4/vendor/win/x86/jpegtran.exe', 'win32', 'x86')
.addUrl('https://raw.github.com/yeoman/node-jpegtran-bin/0.2.4/vendor/win/x64/jpegtran.exe', 'win32', 'x64')
.addFile('https://raw.github.com/yeoman/node-jpegtran-bin/0.2.4/vendor/win/x86/libjpeg-62.dll', 'win32', 'x86')
.addFile('https://raw.github.com/yeoman/node-jpegtran-bin/0.2.4/vendor/win/x64/libjpeg-62.dll', 'win32', 'x64')
.addSource('http://downloads.sourceforge.net/project/libjpeg-turbo/1.3.0/libjpeg-turbo-1.3.0.tar.gz')
.check(args)
.on('error', function (err) {
console.log(chalk.red('✗ ' + err.message));
})
.on('fail', function () {
if (process.platform === 'win32') {
return console.log(chalk.red('✗ building is not supported on ' + process.platform));
}
bin.run(args, function (err) {
if (err) {
console.log(chalk.red('✗ pre-build test failed, compiling from source...'));
this.build(bs);
})
.on('success', function () {
console.log(chalk.green('✓ pre-build test passed successfully'));
})
.on('finish', function () {
console.log(chalk.green('✓ jpegtran rebuilt successfully'));
});
var builder = new BinBuild()
.src('http://downloads.sourceforge.net/project/libjpeg-turbo/1.3.0/libjpeg-turbo-1.3.0.tar.gz')
.cfg('./configure --disable-shared --prefix="' + bin.dest() + '" --bindir="' + bin.dest() + '"')
.make('make install');
return builder.build(function (err) {
if (err) {
return console.log(chalk.red('✗ ' + err));
}
console.log(chalk.green('✓ jpegtran built successfully'));
});
}
console.log(chalk.green('✓ pre-build test passed successfully'));
});
}

@@ -72,2 +69,2 @@ });

module.exports.path = bin.path;
module.exports.path = bin.use();
{
"name": "jpegtran-bin",
"version": "0.2.6",
"description": "jpegtran (part of libjpeg-turbo) 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.",
"keywords": [
"jpeg",
"jpg",
"img",
"image",
"compress",
"minify",
"optimize"
],
"homepage": "https://github.com/yeoman/node-jpegtran-bin",
"bugs": "https://github.com/yeoman/node-jpegtran-bin/issues",
"license": "BSD",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"maintainers": [
{
"name": "Kevin Martensson",
"email": "kevinmartensson@gmail.com",
"url": "http://kevinmartensson.com"
}
],
"main": "index.js",
"bin": {
"jpegtran": "cli.js"
},
"repository": {
"type": "git",
"url": "git://github.com/yeoman/node-jpegtran-bin.git"
},
"scripts": {
"test": "mocha --reporter list --timeout 0",
"postinstall": "node index.js"
},
"engines": {
"node": ">=0.10.0"
},
"dependencies": {
"bin-wrapper": "~0.2.0",
"chalk": "~0.4.0"
},
"devDependencies": {
"bin-check": "~0.1.0",
"mocha": "~1.18.2",
"rimraf": "~2.2.6"
},
"files": [
"cli.js",
"index.js",
"test"
]
"name": "jpegtran-bin",
"version": "0.2.7",
"description": "jpegtran (part of libjpeg-turbo) wrapper that makes it seamlessly available as a local dependency on OS X, Linux, FreeBSD, Solaris and Windows",
"license": "BSD",
"repository": "imagemin/jpegtran-bin",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "http://sindresorhus.com"
},
"maintainers": [
{
"name": "Kevin Mårtensson",
"email": "kevinmartensson@gmail.com",
"url": "http://kevinmartensson.com"
}
],
"engines": {
"node": ">=0.10.0"
},
"bin": {
"jpegtran": "cli.js"
},
"scripts": {
"test": "mocha --reporter list --timeout 0",
"postinstall": "node index.js"
},
"files": [
"cli.js",
"index.js",
"test"
],
"keywords": [
"compress",
"image",
"img",
"jpeg",
"jpg",
"minify",
"optimize"
],
"dependencies": {
"bin-build": "^0.1.0",
"bin-wrapper": "^0.3.0",
"chalk": "^0.4.0"
},
"devDependencies": {
"bin-check": "^0.1.0",
"mocha": "^1.18.2",
"rimraf": "^2.2.6"
}
}

@@ -1,2 +0,2 @@

# node-jpegtran-bin [![Build Status](https://secure.travis-ci.org/yeoman/node-jpegtran-bin.png?branch=master)](http://travis-ci.org/yeoman/node-jpegtran-bin)
# jpegtran-bin [![Build Status](https://secure.travis-ci.org/imagemin/jpegtran-bin.svg?branch=master)](http://travis-ci.org/imagemin/jpegtran-bin)

@@ -10,26 +10,43 @@ jpegtran 1.3 (part of [libjpeg-turbo](http://libjpeg-turbo.virtualgl.org/)) 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.

- Install with [npm](https://npmjs.org/package/jpegtran-bin): `npm install --save jpegtran-bin`
```bash
$ npm install --save jpegtran-bin
```
## Example usage
## Usage
```js
var execFile = require('child_process').execFile;
var jpegtranPath = require('jpegtran-bin').path;
var jpegtran = require('jpegtran-bin').path;
execFile(jpegtranPath, ['-outfile', 'output.jpg', 'input.jpg'], function() {
console.log('Image minified');
execFile(jpegtran, ['-outfile', 'output.jpg', 'input.jpg'], function (err) {
if (err) {
throw err;
}
console.log('Image minified!');
});
```
Can also be run directly from `./node_modules/.bin/jpegtran`.
## CLI
## Dev
```bash
$ npm install --global jpegtran-bin
```
Note to self on how to update the binaries.
```bash
$ jpegtran --help
```
## Development
Instructions for manually compiling jpegtran:
### OS X and Linux
- Run `npm install` to build the binary.
```bash
$ npm install
```

@@ -40,11 +57,7 @@ The `nasm` (Netwide Assember) package is required to build the binary on Ubuntu.

- Download the [Windows files 32/64-bit](http://sourceforge.net/projects/libjpeg-turbo/files/) (GCC compiled) on a Windows machine
* Download the [Windows files 32/64-bit](http://sourceforge.net/projects/libjpeg-turbo/files/) (GCC compiled) on a Windows machine
* Run the downloaded file to extract
* In the extracted folder go to the `bin` folder and copy `jpegtran.exe` and `libjpeg-62.dll` to `jpegtran-bin/vendor/` folder
(current version 1.3.0, x64 `libjpeg-turbo-1.3.0-gcc64.exe` and for x86 `libjpeg-turbo-1.3.0-gcc.exe`)
- Run the downloaded file to extract
- In the extracted folder go to the `bin` folder and copy `jpegtran.exe` and `libjpeg-62.dll` to `jpegtran-bin\vendor\` folder
(for `grunt-contrib-imagemin` the folder is `grunt-contrib-imagemin\node_modules\jpegtran-bin\vendor\`)
## License

@@ -51,0 +64,0 @@

@@ -6,6 +6,6 @@ /*global afterEach, beforeEach, describe, it */

var binCheck = require('bin-check');
var BinWrapper = require('bin-wrapper');
var BinBuild = require('bin-build');
var execFile = require('child_process').execFile;
var fs = require('fs');
var path = require('path');
var spawn = require('child_process').spawn;
var rm = require('rimraf');

@@ -18,17 +18,18 @@

beforeEach(function (cb) {
fs.mkdir(path.join(__dirname, 'tmp'), cb);
beforeEach(function () {
fs.mkdirSync(path.join(__dirname, 'tmp'));
});
it('should rebuild the jpegtran binaries', function (cb) {
var bin = new BinWrapper({ bin: 'jpegtran', dest: path.join(__dirname, 'tmp') });
var bs = './configure --disable-shared ' +
'--prefix="' + bin.dest + '" && ' + 'make install';
var tmp = path.join(__dirname, 'tmp');
var builder = new BinBuild()
.src('http://downloads.sourceforge.net/project/libjpeg-turbo/1.3.0/libjpeg-turbo-1.3.0.tar.gz')
.cfg('./configure --disable-shared --prefix="' + tmp + '" --bindir="' + tmp + '"')
.make('make install');
bin
.addSource('http://downloads.sourceforge.net/project/libjpeg-turbo/1.3.0/libjpeg-turbo-1.3.0.tar.gz')
.build(bs)
.on('finish', function () {
cb(assert(true));
});
builder.build(function (err) {
assert(!err);
assert(fs.existsSync(path.join(tmp, 'jpegtran')));
cb();
});
});

@@ -38,3 +39,2 @@

var binPath = require('../').path;
var args = [

@@ -61,3 +61,3 @@ '-copy', 'none',

spawn(binPath, args).on('close', function () {
execFile(binPath, args, function () {
var src = fs.statSync(path.join(__dirname, 'fixtures/test.jpg')).size;

@@ -64,0 +64,0 @@ var dest = fs.statSync(path.join(__dirname, 'tmp/test.jpg')).size;

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