Coder Social home page Coder Social logo

node-smushit's Introduction

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

  • modify the lib/smushit.js, change the regexp /.+\// -> /.+[\/\\]/ bugfix: wrong filename writed to the request body under Windows.

v0.5.0

  • modify the cli.js file to unix format for resolving issue #4

v0.4.0

  • change path.existsSync to fs.existsSync

v0.3.0

  • add custom smushit serivce feature
  • add global service config for CLI
  • can save the smashed file by new name

v0.2.0

  • add callback while the image(s) smashed completed

v0.1.0

  • smash by file, filelist, directory

node-smushit's People

Contributors

colorhook avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

node-smushit's Issues

use all cmd return `saving 0`

cmd :

smushit WechatIMG21.png -o fd.png

result :

[smushit] start smash WechatIMG21.png
[smushit] item: WechatIMG21.png response:
[smushit] smushit completed: total 1, saving 0

How to save result images?

my own smushit service?

/**

  • 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.
    */

how can I create my own smushit service, or are there any existing servies i can use in China?

Request fail

httpRequest.write(postData.builder, "binary"); 

It has returned false for all requests

"env: node\r: No such file or directory" for smushit CLI on OSX

When I run the smushit CLI on OSX I get the following error:

env: node\r: No such file or directory

This is because the file is in DOS format (line endings in particular). I was able to resolve it by converting the file to a unix format:

$ brew install dos2unix
$ sudo dos2unix /usr/local/lib/node_modules/node-smushit/cli.js

I was able to determine what the problem was because of a similar issue reported here: CSSLint/csslint#82.

你好啊

HI,廖健:你好啊!
(我其实不是来提issues的,看完就删了吧。)
我们同事曾经发邮件给你,可能你没看到,于是我在这里给你留言。
我们有个项目是电子商务和云计算交叉的领域,在招募技术人才。看到你的个人信息,看能否交流一下有没有共事或技术合作的机会。我们全职,兼职,远程都有JOB提供。联系QQ: 2355679565 或通过我们的网站WWW.SHOP123.COM您了解一下。最好有机会电话沟通一下,你看方便吗?even手机13750813289 ,谢谢

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.