Socket
Socket
Sign inDemoInstall

optipng-bin

Package Overview
Dependencies
Maintainers
7
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

optipng-bin - npm Package Compare versions

Comparing version 0.3.11 to 1.0.0

lib/index.js

60

index.js
'use strict';
var BinBuild = require('bin-build');
var BinWrapper = require('bin-wrapper');
var fs = require('fs');
var logSymbols = require('log-symbols');
var path = require('path');
var pkg = require('./package.json');
var bin = require('./lib');
/**
* Variables
*/
var BIN_VERSION = '0.7.5';
var BASE_URL = 'https://raw.github.com/imagemin/optipng-bin/v' + pkg.version + '/vendor/';
/**
* Initialize a new BinWrapper
*/
var bin = new BinWrapper()
.src(BASE_URL + 'osx/optipng', 'darwin')
.src(BASE_URL + 'linux/x86/optipng', 'linux', 'x86')
.src(BASE_URL + 'linux/x64/optipng', 'linux', 'x64')
.src(BASE_URL + 'freebsd/optipng', 'freebsd')
.src(BASE_URL + 'sunos/x86/optipng', 'sunos', 'x86')
.src(BASE_URL + 'sunos/x64/optipng', 'sunos', 'x64')
.src(BASE_URL + 'win/optipng.exe', 'win32')
.dest(path.join(__dirname, 'vendor'))
.use(process.platform === 'win32' ? 'optipng.exe' : 'optipng');
/**
* Only run check if binary doesn't already exist
*/
fs.exists(bin.use(), function (exists) {
if (!exists) {
bin.run(['--version'], function (err) {
if (err) {
console.log(logSymbols.warning + ' pre-build test failed, compiling from source...');
var builder = new BinBuild()
.src('http://downloads.sourceforge.net/project/optipng/OptiPNG/optipng-' + BIN_VERSION + '/optipng-' + BIN_VERSION + '.tar.gz')
.cfg('./configure --with-system-zlib --prefix="' + bin.dest() + '" --bindir="' + bin.dest() + '"')
.make('make install');
return builder.build(function (err) {
if (err) {
console.log(logSymbols.error, err);
}
console.log(logSymbols.success + ' optipng built successfully!');
});
}
console.log(logSymbols.success + ' pre-build test passed successfully!');
});
}
});
/**
* Module exports
*/
module.exports.path = bin.use();
module.exports.path = bin.path();
{
"name": "optipng-bin",
"version": "0.3.11",
"version": "1.0.0",
"description": "OptiPNG wrapper that makes it seamlessly available as a local dependency on OS X, Linux, FreeBSD and Windows",
"license": "BSD",
"license": "MIT",
"repository": "imagemin/optipng-bin",

@@ -26,3 +26,3 @@ "author": {

"scripts": {
"postinstall": "node index.js",
"postinstall": "node lib/install.js",
"test": "mocha --reporter list --timeout 50000"

@@ -32,3 +32,4 @@ },

"cli.js",
"index.js"
"index.js",
"lib"
],

@@ -44,8 +45,8 @@ "keywords": [

"dependencies": {
"bin-build": "^0.1.0",
"bin-wrapper": "^0.3.0",
"bin-build": "^0.2.0",
"bin-wrapper": "^0.4.0",
"log-symbols": "^1.0.0"
},
"devDependencies": {
"bin-check": "^0.1.0",
"bin-check": "^1.0.0",
"mocha": "^1.18.2",

@@ -52,0 +53,0 @@ "rimraf": "^2.2.6"

# optipng-bin [![Build Status](https://secure.travis-ci.org/imagemin/optipng-bin.svg?branch=master)](http://travis-ci.org/imagemin/optipng-bin)
[OptiPNG](http://optipng.sourceforge.net) 0.7.4 Node.js wrapper that makes it seamlessly available as a local dependency on OS X, Linux, FreeBSD, Solaris and Windows.
> [OptiPNG](http://optipng.sourceforge.net) is a PNG optimizer that recompresses
image files to a smaller size, without losing any information.
> OptiPNG is a PNG optimizer that recompresses image files to a smaller size, without losing any information.
## Install

@@ -21,4 +20,8 @@

execFile(optipng, ['-v'], function (err, stdout, stderr) {
console.log('OptiPNG version:', stdout.match(/\d\.\d\.\d/)[0]);
execFile(optipng, ['-out', 'output.png', 'input.png'], function (err) {
if (err) {
throw err;
}
console.log('Image minified!');
});

@@ -41,4 +44,5 @@ ```

Everything excluding the binaries licensed under the [BSD license](http://opensource.org/licenses/bsd-license.php) and copyright Google.
MIT © [imagemin](https://github.com/imagemin)
OptiPNG licensed under the [zlib license](http://optipng.sourceforge.net/license.txt) and copyright Cosmin Truta and the Contributing Authors.
OptiPNG licensed under the [zlib license](http://optipng.sourceforge.net/license.txt)
and copyright Cosmin Truta and the Contributing Authors.
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