Skip to content

Commit

Permalink
Updated image
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Totten committed Mar 24, 2016
1 parent 04fcaa6 commit 3c71b22
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
Binary file modified media/articles/libraries/lock/v10/signupcustom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 29 additions & 13 deletions tools.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
var program = require('commander');
var fs = require('fs');
var path = require('path');
var Imagemin = require('imagemin');
var imageminOptipng = require('imagemin-optipng');

var redirectFilePath = './redirect-urls.json';
var addRedirect = function(oldUrl, newUrl, callback) {
fs.readFile(redirectFilePath, function(err, json) {
if (err) { return callback(err); }
var addRedirect = function(oldUrl, newUrl, callback) {
fs.readFile(redirectFilePath, function(err, json) {
if (err) { return callback(err); }

var data = JSON.parse(json);
data.push({
from: oldUrl,
to: newUrl
});
var data = JSON.parse(json);
data.push({
from: oldUrl,
to: newUrl
});

json = JSON.stringify(data, null, 2);
fs.writeFile(redirectFilePath, json, callback);
});
};
json = JSON.stringify(data, null, 2);
fs.writeFile(redirectFilePath, json, callback);
});
};


program
Expand Down Expand Up @@ -46,7 +47,7 @@ program.command('mv <oldUrl> <newUrl>')
});


program.command('img')
program.command('imgs')
.action(function() {
new Imagemin()
.src('media/**/*.png')
Expand All @@ -61,6 +62,21 @@ program.command('img')
});
});

program.command('img <imgPath>')
.action(function(imgPath) {
new Imagemin()
.src(imgPath)
.dest(path.dirname(imgPath))
.use(imageminOptipng({optimizationLevel: 3}))
.run((err, files) => {
if (err) {
console.error(err);
}
console.log('Minified ' + files.length + ' images.');
//=> {path: 'build/images/foo.jpg', contents: <Buffer 89 50 4e ...>}
});
});




Expand Down

0 comments on commit 3c71b22

Please sign in to comment.