# node-smushit

> node-smushit =====

Latest version **0.5.1** (published 2013-01-23) · 0 weekly downloads

## Install

```sh
npm install node-smushit
pnpm add node-smushit
yarn add node-smushit
bun add node-smushit
```

Provides the command `smushit`.

## Health

**Score 10/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.1 |
| Published | 2013-01-23 |
| First published | 2012-04-02 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.8.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 80 |
| Author | colorhook |
| Maintainers | colorhook |
| Keywords | image, compressor, compression |

## Links

- npm: https://www.npmjs.com/package/node-smushit
- Repository: http://github.com/colorhook/node-smushit
- npm.io page: https://npm.io/package/node-smushit

## Dependencies (1)

- [optimist](https://npm.io/package/optimist.md) >= 0.2.6

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 0.5.1 (latest) — 2013-01-23
- 0.5.0 — 2013-01-17
- 0.4.0 — 2012-11-05
- 0.3.0 — 2012-06-26
- 0.2.0 — 2012-06-18
- 0.1.0 — 2012-04-02

## README

node-smushit
=====

using smush.it service to optimize image(s) in node

How to use?
------------

install by NPM

```shell
npm install node-smushit -g
```

use smushit in shell

```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

```javascript
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

---
_Source: https://npm.io/package/node-smushit · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
