An open API service indexing awesome lists of open source software.

https://github.com/tinify/tinify-nodejs

Node.js client for the Tinify API.
https://github.com/tinify/tinify-nodejs

compression image-processing node-js npm-package tinyjpg tinypng

Last synced: 2 months ago
JSON representation

Node.js client for the Tinify API.

Awesome Lists containing this project

README

        

[![NPM Version](https://img.shields.io/npm/v/tinify)](https://www.npmjs.com/package/tinify)

# Tinify API client for Node.js

Node.js client for the Tinify API, used for [TinyPNG](https://tinypng.com) and [TinyJPG](https://tinyjpg.com). Tinify compresses your images intelligently. Read more at [http://tinify.com](http://tinify.com).

## Documentation

[Go to the documentation for the Node.js client](https://tinypng.com/developers/reference/nodejs).

## Installation

Install the API client:

```
npm install tinify
```

Or add this to your `package.json`:

```json
{
"dependencies": {
"tinify": "*"
}
}
```

## Usage

```javascript
const tinify = require("tinify");
tinify.key = "YOUR_API_KEY";

tinify.fromFile("unoptimized.png").toFile("optimized.png");
```

## Running tests

```
npm install
npm test
```

### Integration tests

```
npm install
TINIFY_KEY=$YOUR_API_KEY npm run integration
```

#### To test with proxy:

$ docker run --rm -it -v ~/.mitmproxy:/home/mitmproxy/.mitmproxy -p 8080:8080 mitmproxy/mitmproxy mitmproxy --listen-host 0.0.0.0

$ TINIFY_PROXY=http://172.17.0.3:8080 npm run integration

## License

This software is licensed under the MIT License. [View the license](LICENSE).