first commit
This commit is contained in:
64
build/node_modules/node-zopfli/bin/zopfli
generated
vendored
Executable file
64
build/node_modules/node-zopfli/bin/zopfli
generated
vendored
Executable file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
var program = require('commander');
|
||||
var fs = require('fs');
|
||||
var zopfli = require('../lib/zopfli');
|
||||
|
||||
program
|
||||
.version(require('../package.json').version)
|
||||
.usage('[options] [files...]')
|
||||
.option('--deflate', 'raw deflate (without container)')
|
||||
.option('--zlib', 'deflate using zlib container')
|
||||
.option('--gzip', 'deflate using gzip container')
|
||||
.option('-e, --ext <s>', 'overwrite default file extension')
|
||||
.option('-i, --iterations <n>', 'number of iterations (higher = smaller = slower)', parseInt)
|
||||
.option('-v, --verbose', 'Verbose')
|
||||
.parse(process.argv);
|
||||
|
||||
var options = {
|
||||
verbose: false,
|
||||
verbose_more: false,
|
||||
numiterations: 15,
|
||||
blocksplitting: true,
|
||||
blocksplittinglast: false,
|
||||
blocksplittingmax: 15
|
||||
};
|
||||
|
||||
if (program.iterations) options.numiterations = parseInt(program.iterations, 10);
|
||||
if (program.verbose) options.verbose = program.verbose;
|
||||
|
||||
var method = zopfli.createGzip;
|
||||
var extension = 'gz';
|
||||
|
||||
if (program.deflate) {
|
||||
method = zopfli.createDeflate;
|
||||
extension = 'deflate';
|
||||
}
|
||||
if (program.zlib) {
|
||||
method = zopfli.createZlib;
|
||||
extension = 'zlib';
|
||||
}
|
||||
if (program.ext) {
|
||||
extension = program.ext;
|
||||
}
|
||||
|
||||
if (program.args.length === 0) {
|
||||
program.outputHelp();
|
||||
process.exit(1);
|
||||
} else {
|
||||
Promise.all(
|
||||
program.args.map(function(item) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
fs.createReadStream(item)
|
||||
.on('error', reject)
|
||||
.pipe(new method(options))
|
||||
.on('error', reject)
|
||||
.pipe(fs.createWriteStream(item + '.' + extension))
|
||||
.on('error', reject)
|
||||
.on('finish', resolve);
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
56
build/node_modules/node-zopfli/bin/zopflipng
generated
vendored
Executable file
56
build/node_modules/node-zopfli/bin/zopflipng
generated
vendored
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
'use strict';
|
||||
|
||||
var program = require('commander');
|
||||
var fs = require('fs');
|
||||
var binary = require('node-pre-gyp');
|
||||
var path = require('path');
|
||||
var binding_path = binary.find(path.join(__dirname, '../package.json'));
|
||||
var zopfli = require(binding_path);
|
||||
|
||||
program
|
||||
.version(require('../package.json').version)
|
||||
.usage('[options] file destfile')
|
||||
.option('--lossy_transparent', 'Allow altering hidden colors of fully transparent pixels')
|
||||
.option('--lossy', 'Convert 16-bit per channel images to 8-bit per channel')
|
||||
.option('--filter_strategies', 'Filter strategies to try : "zero", "one", "two", "three", "four", "minimum", "entropy", "predefined", "brute", if none, it will be guessed automatically')
|
||||
.option('--keepchunks', 'Chunks to keep')
|
||||
.option('--iterations=<n>', 'Number of iterations for small images < 200 KiB', parseInt)
|
||||
.option('--iterations_large=<n>', 'Number of iterations for large images > 200 KiB', parseInt)
|
||||
.parse(process.argv);
|
||||
|
||||
var options = {
|
||||
lossy_transparent: false,
|
||||
lossy_8bit: false,
|
||||
filter_strategies: [],
|
||||
auto_filter_strategy: true,
|
||||
keepchunks: [],
|
||||
use_zopfli: true,
|
||||
num_iterations: 15,
|
||||
num_iterations_large: 5,
|
||||
block_split_strategy: 'both' // Split chunk strategy none, first, last, both
|
||||
};
|
||||
|
||||
options.lossy_transparent = !!program.lossy_transparent;
|
||||
options.lossy_8bit = !!program.lossy;
|
||||
// if (program.filter_strategies) options.filter_strategies = []; //TODO
|
||||
// if (program.keepchunks) options.keepchunks = []; //TODO
|
||||
options.num_iterations = program.iterations || options.num_iterations;
|
||||
options.num_iterations_large = program.iterations_large || options.num_iterations_large;
|
||||
|
||||
if (typeof program.args[0] !== 'string') {
|
||||
console.log('You must provide a file to compress');
|
||||
process.exit(1);
|
||||
}
|
||||
if (typeof program.args[1] !== 'string') {
|
||||
console.log('You must provide a destination file');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
if (fs.existsSync(program.args[0])) {
|
||||
zopfli.pngcompress(program.args[0], program.args[1], options);
|
||||
} else {
|
||||
console.log('File ' + program.args[0] + ' doesn\'t exist');
|
||||
process.exit(1);
|
||||
}
|
||||
Reference in New Issue
Block a user