imgcraft 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -68
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="https://imgcraft-docs.vercel.app/logo.png" height="96" alt="imgcraft" />
|
|
3
|
+
</p>
|
|
2
4
|
|
|
3
|
-
|
|
5
|
+
<p align="center">
|
|
6
|
+
<a href="https://www.npmjs.com/package/imgcraft"><img src="https://img.shields.io/npm/v/imgcraft.svg" alt="npm version" /></a>
|
|
7
|
+
<a href="https://github.com/ajithonmain/imgcraft/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/imgcraft.svg" alt="license" /></a>
|
|
8
|
+
<a href="https://github.com/ajithonmain/imgcraft/actions"><img src="https://img.shields.io/badge/tests-65%20passing-brightgreen.svg" alt="tests" /></a>
|
|
9
|
+
<a href="https://www.npmjs.com/package/imgcraft"><img src="https://img.shields.io/npm/dm/imgcraft" alt="npm downloads" /></a>
|
|
10
|
+
</p>
|
|
4
11
|
|
|
5
|
-
|
|
6
|
-
[](https://www.typescriptlang.org/)
|
|
7
|
-
[](LICENSE)
|
|
12
|
+
<p align="center"><b>Chainable image transforms for Node.js and the browser — with AI ops built in.</b></p>
|
|
8
13
|
|
|
9
14
|
## Install
|
|
10
15
|
|
|
@@ -12,87 +17,77 @@ Chainable image transforms for Node + Browser.
|
|
|
12
17
|
npm install imgcraft
|
|
13
18
|
```
|
|
14
19
|
|
|
15
|
-
Node.js
|
|
20
|
+
Node.js requires [sharp](https://sharp.pixelplumbing.com/) as an optional peer dep. Browser uses WASM — no extra install.
|
|
16
21
|
|
|
17
22
|
## Usage
|
|
18
23
|
|
|
19
24
|
```ts
|
|
20
25
|
import { img, batch } from 'imgcraft'
|
|
21
26
|
|
|
22
|
-
//
|
|
23
|
-
const
|
|
24
|
-
.resize(800
|
|
27
|
+
// Resize + remove background + convert — in one chain
|
|
28
|
+
const buffer = await img('photo.jpg')
|
|
29
|
+
.resize(800)
|
|
30
|
+
.removeBackground()
|
|
25
31
|
.webp({ quality: 85 })
|
|
26
32
|
.toBuffer()
|
|
27
33
|
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
.resize(400)
|
|
31
|
-
.removeBackground()
|
|
32
|
-
.toDataURL()
|
|
33
|
-
|
|
34
|
-
// Batch
|
|
35
|
-
await batch(['a.jpg', 'b.jpg', 'c.jpg'])
|
|
34
|
+
// Batch process with concurrency control
|
|
35
|
+
await batch(['a.jpg', 'b.jpg', 'c.jpg'], { concurrency: 4 })
|
|
36
36
|
.resize(1200)
|
|
37
37
|
.webp()
|
|
38
38
|
.toDir('./output')
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
##
|
|
41
|
+
## Why imgcraft?
|
|
42
42
|
|
|
43
|
-
| Feature |
|
|
44
|
-
|
|
45
|
-
|
|
|
46
|
-
|
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
43
|
+
| Feature | imgcraft | sharp |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| Chainable API | ✅ | ✅ |
|
|
46
|
+
| Node.js | ✅ | ✅ |
|
|
47
|
+
| Browser (WASM) | ✅ | ❌ |
|
|
48
|
+
| AI background removal | ✅ | ❌ |
|
|
49
|
+
| Smart crop | ✅ | ❌ |
|
|
50
|
+
| AI upscaling | ✅ | ❌ |
|
|
51
|
+
| Hosted REST API | ✅ | ❌ |
|
|
52
|
+
| TypeScript strict | ✅ | ✅ |
|
|
51
53
|
|
|
52
54
|
## API
|
|
53
55
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
| Method | Returns |
|
|
89
|
-
|---|---|
|
|
90
|
-
| `.toBuffer()` | `Buffer` (Node) / `Uint8Array` (Browser) |
|
|
91
|
-
| `.toFile(path)` | `Promise<void>` — Node only |
|
|
92
|
-
| `.toStream()` | `ReadableStream<Uint8Array>` |
|
|
93
|
-
| `.toDataURL()` | `Promise<string>` — base64 data URI |
|
|
94
|
-
| `.meta()` | `Promise<MetadataResult>` — reads metadata, no processing |
|
|
56
|
+
```ts
|
|
57
|
+
img(input)
|
|
58
|
+
.resize(width?, height?, options?)
|
|
59
|
+
.crop(left, top, width, height)
|
|
60
|
+
.rotate(angle)
|
|
61
|
+
.flip() / .flop()
|
|
62
|
+
.format('webp' | 'jpeg' | 'png' | 'avif')
|
|
63
|
+
.quality(1-100)
|
|
64
|
+
.blur(sigma?) / .sharpen() / .grayscale()
|
|
65
|
+
.brightness(factor) / .contrast(factor) / .saturation(factor)
|
|
66
|
+
.tint(color) / .negate()
|
|
67
|
+
.composite(input, options?)
|
|
68
|
+
.removeBackground() // AI — no API key needed
|
|
69
|
+
.smartCrop(options?) // AI — subject-aware crop
|
|
70
|
+
.upscale(2 | 4) // AI — ESRGAN upscaling
|
|
71
|
+
.meta() // read metadata
|
|
72
|
+
.stripMeta() // strip EXIF
|
|
73
|
+
.toBuffer() // → Buffer (Node) / Uint8Array (browser)
|
|
74
|
+
.toFile(path) // → write to disk (Node)
|
|
75
|
+
.toStream() // → ReadableStream
|
|
76
|
+
.toDataURL() // → base64 data URI (browser)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## REST API
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
POST https://imgcraft-api.imgcraft.workers.dev/transform
|
|
83
|
+
POST https://imgcraft-api.imgcraft.workers.dev/info
|
|
84
|
+
GET https://imgcraft-api.imgcraft.workers.dev/health
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Links
|
|
88
|
+
|
|
89
|
+
**[Docs](https://imgcraft-docs.vercel.app)** · **[Playground](https://imgcraft-docs.vercel.app/playground)** · **[GitHub](https://github.com/ajithonmain/imgcraft)**
|
|
95
90
|
|
|
96
91
|
## License
|
|
97
92
|
|
|
98
|
-
MIT
|
|
93
|
+
MIT © 2026 Ajith M Jose
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "imgcraft",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Chainable image transform pipeline — Node + Browser WASM",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/ajithonmain/imgcraft.git"
|
|
8
|
+
"url": "git+https://github.com/ajithonmain/imgcraft.git"
|
|
9
9
|
},
|
|
10
|
-
"homepage": "https://imgcraft.
|
|
10
|
+
"homepage": "https://imgcraft-docs.vercel.app",
|
|
11
11
|
"keywords": [
|
|
12
12
|
"image",
|
|
13
13
|
"image-processing",
|