Home

Awesome

node-smushit

using smush.it service to optimize image(s) in node

How to use?

install by NPM

npm install node-smushit -g

use smushit in shell

//view help
smushit -h

//smash files or directory
smushit file1 file2 file3

//with recursive
smushit file1 file2 file3 -R


//smash file and save by new name
smushit image-file-name -o new-file-name


/**
 * change the default service.
 * by default, `node-smushit` use the !Yahoo smushi.it service, you can create your owne smush service.
 * If you are in China, you will know how important to create your own smush.it service. 
 * FUCK THE GFW & POOR NETWORK SPEED.
 */

// view all config
smushit -c

//view service endpoint config, indicate the smush.it HTTP service
smushit -c service

//change the config
smushit -c service=http://your-own-service-endpoint/

use it in node

var smushit = require('node-smushit');
//smash a single file
smushit.smushit('images/need-to-smash.png');

//smash files
smushit.smushit(['file1', 'fiel2', ..]);

//smash images in directory
smushit.smushit('images-folder-path');

//smash images in directory or the child-directories with recursive
smushit.smushit('images-folder-path', {recursive: true});

//smash images and register callbacks
smushit.smushit('images-folder-path', {
    onItemStart: function(item){
	
    },
    onItemComplete: function(e, item, response){
	
    },
    onComplete: function(reports){
	
    },
    service: 'http://my-custom-domain-service/'
});

Changelog

v0.5.1

v0.5.0

v0.4.0

v0.3.0

v0.2.0

v0.1.0