imgcraft 0.1.3 → 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.
Files changed (2) hide show
  1. package/README.md +63 -68
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -1,10 +1,15 @@
1
- # imgcraft
1
+ <p align="center">
2
+ <img src="https://imgcraft-docs.vercel.app/logo.png" height="96" alt="imgcraft" />
3
+ </p>
2
4
 
3
- Chainable image transforms for Node + Browser.
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
- [![npm version](https://img.shields.io/npm/v/imgcraft.svg)](https://www.npmjs.com/package/imgcraft)
6
- [![license](https://img.shields.io/npm/l/imgcraft.svg)](https://github.com/ajithonmain/imgcraft/blob/main/LICENSE)
7
- [![tests](https://img.shields.io/badge/tests-65%20passing-brightgreen.svg)](https://github.com/ajithonmain/imgcraft/actions)
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 uses [sharp](https://sharp.pixelplumbing.com/) under the hood (optional peer dep). Browser uses WASM — no extra install.
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
- // Node
23
- const buf = await img('photo.jpg')
24
- .resize(800, 600)
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
- // Browser (same API, WASM engine auto-selected)
29
- const url = await img(file)
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
- ## Features
41
+ ## Why imgcraft?
42
42
 
43
- | Feature | Status |
44
- |---|---|
45
- | Node.js (sharp engine) | ✅ |
46
- | Browser (WASM engine) | ✅ |
47
- | AI ops (bg removal, smart crop, upscale) | ✅ |
48
- | TypeScript strict | ✅ |
49
- | Zero config | ✅ |
50
- | Tree-shakeable ESM | ✅ |
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
- ### Transform
55
-
56
- | Method | Description |
57
- |---|---|
58
- | `.resize(w?, h?, opts?)` | Resize. `opts.fit`: cover / contain / fill / inside / outside |
59
- | `.crop({ left, top, width, height })` | Extract a region |
60
- | `.rotate(angle, opts?)` | Rotate by degrees |
61
- | `.flip()` | Flip vertically |
62
- | `.flop()` | Flip horizontally |
63
- | `.format(type, opts?)` | Set output format: jpeg / png / webp / avif / tiff |
64
- | `.jpeg(opts?)` `.png(opts?)` `.webp(opts?)` `.avif(opts?)` | Format shorthands |
65
- | `.quality(1–100)` | Set output quality |
66
- | `.blur(sigma?)` | Gaussian blur |
67
- | `.sharpen(opts?)` | Unsharp mask |
68
- | `.median(size?)` | Median filter |
69
- | `.grayscale()` | Convert to greyscale |
70
- | `.tint({ r, g, b })` | Apply color tint |
71
- | `.negate()` | Invert colors |
72
- | `.brightness(value)` | Brightness multiplier (1 = no change) |
73
- | `.contrast({ value })` | Contrast multiplier (1 = no change) |
74
- | `.saturation(value)` | Saturation multiplier |
75
- | `.composite(opts)` | Overlay / watermark |
76
- | `.stripMeta()` | Remove EXIF and ICC metadata |
77
-
78
- ### AI
79
-
80
- | Method | Description |
81
- |---|---|
82
- | `.removeBackground()` | ONNX-based bg removal, runs locally, no API key |
83
- | `.smartCrop(subject)` | Face / object aware crop |
84
- | `.upscale(factor)` | 2× or 4× via ESRGAN |
85
-
86
- ### Output
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,11 +1,11 @@
1
1
  {
2
2
  "name": "imgcraft",
3
- "version": "0.1.3",
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
10
  "homepage": "https://imgcraft-docs.vercel.app",
11
11
  "keywords": [