Skip to content

Commit aa41597

Browse files
committed
Extend the README a bit
1 parent 18cbad3 commit aa41597

1 file changed

Lines changed: 46 additions & 5 deletions

File tree

README.md

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,27 @@
11
[![NPM Version](https://img.shields.io/npm/v/tinify)](https://www.npmjs.com/package/tinify)
2+
![NPM License](https://img.shields.io/npm/l/tinify)
23

34

45

56
# Tinify API client for Node.js
67

7-
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).
8+
A lightweight Node.js client for the Tinify API, used for [tinypng API](https://tinypng.com) and [TinyJPG](https://tinyjpg.com). This library lets you intelligently **compress**, **resize**, **convert**, and **store** images (AVIF, WebP, JPEG, PNG) with minimal effort. Read more at [http://tinify.com](http://tinify.com).
89

9-
## Documentation
10+
## 🚀 Features
1011

11-
[Go to the documentation for the Node.js client](https://tinypng.com/developers/reference/nodejs).
12+
- Compress and optimize images in AVIF, WebP, JPEG, and PNG formats
13+
- Resize with intelligent cropping
14+
- Convert between formats
15+
- Preserve metadata (copyright, GPS, creation time)
16+
- Upload directly to Amazon S3, Google Cloud Storage, or custom S3/Azure storage
1217

13-
## Installation
18+
## 📖 Documentation
1419

15-
Install the API client:
20+
[Go to the full documentation for the Node.js client](https://tinypng.com/developers/reference/nodejs).
21+
22+
## 📦 Installation
23+
24+
Install the API client via NPM:
1625

1726
```
1827
npm install tinify
@@ -34,7 +43,39 @@ Or add this to your `package.json`:
3443
const tinify = require("tinify");
3544
tinify.key = "YOUR_API_KEY";
3645

46+
// Basic from file system
3747
tinify.fromFile("unoptimized.png").toFile("optimized.png");
48+
49+
// From URL
50+
tinify.fromUrl("https://tinypng.com/images/panda-happy.png")
51+
.toFile("optimized.png");
52+
53+
// Resize
54+
tinify.fromFile("unoptimized.png").resize({
55+
method: "cover",
56+
width: 150,
57+
height: 100
58+
}).toFile("thumbnail.jpg");
59+
60+
// Convert format
61+
tinify.fromFile("photo.jpg").convert({ type: ["image/webp", "image/png"] })
62+
.result().extension().then(ext => {
63+
return tinify.fromFile("photo.jpg").toFile("photo." + ext);
64+
});
65+
66+
// Preserve metadata
67+
tinify.fromFile("original.jpg")
68+
.preserve("copyright", "location", "creation")
69+
.toFile("with-meta.jpg");
70+
71+
// Store to Amazon S3
72+
tinify.fromFile("upload.jpg").store({
73+
service: "s3",
74+
aws_access_key_id: "KEY",
75+
aws_secret_access_key: "SECRET",
76+
region: "us-west-1",
77+
path: "bucket-name/images/upload.jpg"
78+
});
3879
```
3980

4081
## Running tests

0 commit comments

Comments
 (0)