@boruto_vk7/stickengine 1.2.0 → 2.0.1
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 +102 -235
- package/dist/cjs/StickEngine.js +497 -315
- package/dist/cjs/StickEngine.js.map +1 -1
- package/dist/cjs/compat.js +9 -0
- package/dist/cjs/compat.js.map +1 -0
- package/dist/cjs/index.js +28 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/logo.png +0 -0
- package/dist/cjs/logo_small.png +0 -0
- package/dist/cjs/package.json +1 -1
- package/dist/esm/StickEngine.js +459 -317
- package/dist/esm/StickEngine.js.map +1 -1
- package/dist/esm/compat.js +2 -0
- package/dist/esm/compat.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/logo.png +0 -0
- package/dist/esm/logo_small.png +0 -0
- package/dist/types/StickEngine.d.ts +30 -73
- package/dist/types/StickEngine.d.ts.map +1 -1
- package/dist/types/compat.d.ts +2 -0
- package/dist/types/compat.d.ts.map +1 -0
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.d.ts.map +1 -1
- package/logo.png +0 -0
- package/logo_small.png +0 -0
- package/package.json +21 -38
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -1,306 +1,173 @@
|
|
|
1
|
-
# StickEngine
|
|
1
|
+
# StickEngine - Lagos Solutions
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+

|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Motor profissional de figurinhas para WhatsApp**
|
|
6
|
+
Estático e animado, com EXIF, marca d'água com sua logo e suporte total ESM + CJS + TypeScript
|
|
6
7
|
|
|
7
|
-
[](https://www.npmjs.com/package/@boruto_vk7/stickengine)
|
|
9
|
+
[](https://nodejs.org)
|
|
10
|
+
[](LICENSE)
|
|
11
|
+
[](https://www.npmjs.com/package/@boruto_vk7/stickengine)
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
npm install @boruto_vk7/stickengine
|
|
13
|
-
```
|
|
13
|
+

|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
> SOLUÇÕES INTELIGENTES. RESULTADOS REAIS.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
---
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
## 🚀 Instalação
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
| Animated WebP EXIF crashes (`save` vs `muxAnim`) | **Compatible with node-webpmux v1 + v3** |
|
|
25
|
-
| Oversized animated stickers rejected by WA | **Auto quality/FPS shrink under ~1MB** |
|
|
26
|
-
| Awkward queue-only APIs | **`StickEngine.create()` → `{ buffer, path, base64 }`** |
|
|
27
|
-
| ESM *or* CJS only | **Dual package (import + require)** |
|
|
21
|
+
```bash
|
|
22
|
+
npm install @boruto_vk7/stickengine
|
|
23
|
+
```
|
|
28
24
|
|
|
29
|
-
|
|
25
|
+
FFmpeg já incluso via `@ffmpeg-installer/ffmpeg`. Não precisa instalar manualmente.
|
|
30
26
|
|
|
31
27
|
---
|
|
32
28
|
|
|
33
|
-
##
|
|
34
|
-
|
|
35
|
-
- **Node.js ≥ 18**
|
|
36
|
-
- **ffmpeg** + **ffprobe** available in `PATH`
|
|
37
|
-
(or install `@ffmpeg-installer/ffmpeg` + `@ffprobe-installer/ffprobe` and set paths via `fluent-ffmpeg`)
|
|
29
|
+
## ✨ Funcionalidades
|
|
38
30
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
31
|
+
- ✅ **Todos os tipos de entrada:** Buffer, caminho local, URL https, data URI base64, base64 puro
|
|
32
|
+
- ✅ **Todos os tipos de figurinha:** JPG, PNG, WEBP estático, GIF animado, MP4, WEBM
|
|
33
|
+
- ✅ **5 modos de enquadramento:** `natural` (padrão WA), `cover`, `contain`, `fill`, `none`
|
|
34
|
+
- ✅ **EXIF com pack e autor:** Compatível com node-webpmux v1 e v3
|
|
35
|
+
- ✅ **Auto shrink:** Figurinhas animadas sempre abaixo de 1MB
|
|
36
|
+
- ✅ **Dirtemp custom:** `Dirtemp`, `tempDir`, `dirTemp` - qualquer alias funciona
|
|
37
|
+
- ✅ **Marca d'água com LOGO:** `watermark: true` usa sua `logo.png` automaticamente
|
|
38
|
+
- ✅ **Compatível:** ESM `import`, CJS `require()`, TypeScript `NodeNext` e `CommonJS`
|
|
39
|
+
- ✅ **APIs antigas:** `sendImageAsSticker`, `imageToWebp`, `writeExifImg` ainda funcionam
|
|
46
40
|
|
|
47
41
|
---
|
|
48
42
|
|
|
49
|
-
##
|
|
43
|
+
## 📦 Uso Rápido
|
|
50
44
|
|
|
51
45
|
### ESM / TypeScript
|
|
52
|
-
|
|
53
|
-
```ts
|
|
46
|
+
```javascript
|
|
54
47
|
import StickEngine from '@boruto_vk7/stickengine';
|
|
55
48
|
|
|
56
|
-
const sticker = await StickEngine.create('./
|
|
49
|
+
const sticker = await StickEngine.create('./foto.jpg', {
|
|
50
|
+
Dirtemp: './temp',
|
|
51
|
+
watermark: true,
|
|
57
52
|
metadata: {
|
|
58
|
-
pack: '
|
|
53
|
+
pack: 'Lagos Solutions',
|
|
59
54
|
author: 'Borutovk7',
|
|
60
|
-
emojis: ['
|
|
61
|
-
}
|
|
55
|
+
emojis: ['🔥']
|
|
56
|
+
}
|
|
62
57
|
});
|
|
63
58
|
|
|
64
|
-
// WhatsApp-ready WebP
|
|
65
59
|
await sock.sendMessage(jid, { sticker: sticker.buffer });
|
|
66
60
|
```
|
|
67
61
|
|
|
68
62
|
### CommonJS
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
63
|
+
```javascript
|
|
64
|
+
const StickEngine = require('@boruto_vk7/stickengine');
|
|
65
|
+
|
|
66
|
+
const buffer = await StickEngine.toBuffer('./video.mp4', {
|
|
67
|
+
Dirtemp: '/tmp/meus-stickers',
|
|
68
|
+
watermark: false,
|
|
69
|
+
fit: 'natural',
|
|
70
|
+
metadata: { pack: 'Meu Pack', author: 'Bot' }
|
|
75
71
|
});
|
|
76
72
|
```
|
|
77
73
|
|
|
78
|
-
###
|
|
74
|
+
### Com marca d'água LOGO
|
|
79
75
|
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
```javascript
|
|
77
|
+
await StickEngine.create('./imagem.png', {
|
|
78
|
+
Dirtemp: './temp',
|
|
79
|
+
watermark: true,
|
|
80
|
+
metadata: { pack: 'Lagos', author: 'Solutions' }
|
|
83
81
|
});
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
Accepts **file path**, **http(s) URL**, or **Buffer**.
|
|
87
|
-
|
|
88
|
-
---
|
|
89
|
-
|
|
90
|
-
## Sticker framing (`fit`)
|
|
91
|
-
|
|
92
|
-
By default StickEngine uses **`fit: 'natural'`** — the **real WhatsApp sticker look**:
|
|
93
82
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
Examples: `1080×1920` → `288×512` · `1920×1080` → `512×288`
|
|
99
|
-
|
|
100
|
-
```ts
|
|
101
|
-
await StickEngine.create(input, {
|
|
102
|
-
fit: 'natural', // default — normal WA sticker geometry
|
|
103
|
-
// fit: 'cover', // force 512×512 square (center-crop)
|
|
104
|
-
// fit: 'contain', // square 512×512 + transparent margins
|
|
105
|
-
// fit: 'fill', // stretch (distorts)
|
|
106
|
-
// fit: 'none', // only shrink if larger than 512
|
|
83
|
+
await StickEngine.create('./imagem.png', {
|
|
84
|
+
watermark: { image: './logo.png', position: 'center', size: 0.4, opacity: 0.6 },
|
|
85
|
+
metadata: { pack: 'Pack', author: 'Author' }
|
|
107
86
|
});
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
| `fit` | Look |
|
|
111
|
-
|-------|------|
|
|
112
|
-
| `natural` (default) | Proportional sticker, max side 512 — **normal WA style** |
|
|
113
|
-
| `cover` | Full square 512×512, crops edges |
|
|
114
|
-
| `contain` | Full image in a square, transparent pad (never black) |
|
|
115
|
-
| `fill` | Stretched to square |
|
|
116
|
-
| `none` | Shrink-only if larger than 512 |
|
|
117
|
-
|
|
118
|
-
---
|
|
119
87
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
path: string; // absolute path to .webp
|
|
125
|
-
buffer: Buffer; // send this to WhatsApp
|
|
126
|
-
base64: string; // raw base64 (no data: prefix)
|
|
127
|
-
animated: boolean;
|
|
128
|
-
width: number;
|
|
129
|
-
height: number;
|
|
130
|
-
size: number; // bytes
|
|
131
|
-
}
|
|
88
|
+
await StickEngine.create('./imagem.png', {
|
|
89
|
+
watermark: false,
|
|
90
|
+
metadata: { pack: 'Sem marca', author: 'Bot' }
|
|
91
|
+
});
|
|
132
92
|
```
|
|
133
93
|
|
|
134
94
|
---
|
|
135
95
|
|
|
136
|
-
##
|
|
96
|
+
## 🎨 Modos de Enquadramento
|
|
137
97
|
|
|
138
|
-
```
|
|
139
|
-
await StickEngine.create(input, {
|
|
140
|
-
metadata: {
|
|
141
|
-
pack: 'Pack name shown in WhatsApp',
|
|
142
|
-
author: 'Publisher name',
|
|
143
|
-
emojis: ['🔥', '✨'],
|
|
144
|
-
id: 'optional-stable-pack-id',
|
|
145
|
-
},
|
|
146
|
-
|
|
147
|
-
fit: 'natural', // natural | cover | contain | fill | none
|
|
148
|
-
fps: 15, // animated FPS
|
|
149
|
-
quality: 95, // 1–100 (static default high; anim auto-shrinks)
|
|
150
|
-
maxDuration: 6, // seconds (WA-friendly)
|
|
151
|
-
|
|
152
|
-
edit: {
|
|
153
|
-
// static images only
|
|
154
|
-
circle: true,
|
|
155
|
-
greyscale: false,
|
|
156
|
-
sepia: false,
|
|
157
|
-
blur: 0,
|
|
158
|
-
brightness: 0, // -1 … 1
|
|
159
|
-
contrast: 0, // -1 … 1
|
|
160
|
-
text: {
|
|
161
|
-
content: 'TOP',
|
|
162
|
-
color: 'WHITE',
|
|
163
|
-
stroke: true, // outlined caption
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
|
-
|
|
167
|
-
// transparent: 'REMOVE_BG_API_KEY', // static only (remove.bg)
|
|
168
|
-
autoClean: false,
|
|
169
|
-
tempDir: './tmp_stickengine',
|
|
170
|
-
});
|
|
98
|
+
```javascript
|
|
99
|
+
await StickEngine.create(input, { fit: 'natural' });
|
|
171
100
|
```
|
|
172
101
|
|
|
173
|
-
|
|
|
174
|
-
|
|
175
|
-
| `
|
|
176
|
-
| `
|
|
177
|
-
| `
|
|
178
|
-
| `
|
|
179
|
-
| `
|
|
180
|
-
| `maxDuration` | `6` | Trim long videos/GIFs |
|
|
181
|
-
| `edit` | `false` | Jimp filters (static only) |
|
|
182
|
-
| `transparent` | `false` | remove.bg API key / key list |
|
|
183
|
-
| `autoClean` | `false` | Set `true` only if you manage file lifetime yourself |
|
|
102
|
+
| Fit | Resultado |
|
|
103
|
+
|-----|-----------|
|
|
104
|
+
| `natural` (padrão) | Mantém proporção, lado maior = 512px - visual real do WhatsApp |
|
|
105
|
+
| `cover` | Força 512x512 quadrado com corte central |
|
|
106
|
+
| `contain` | Encaixa dentro de 512x512 com fundo transparente |
|
|
107
|
+
| `fill` | Estica para 512x512 |
|
|
108
|
+
| `none` | Só diminui se maior que 512, nunca aumenta |
|
|
184
109
|
|
|
185
110
|
---
|
|
186
111
|
|
|
187
|
-
##
|
|
112
|
+
## 📁 Dirtemp Personalizado
|
|
188
113
|
|
|
189
|
-
|
|
114
|
+
Aceita qualquer alias:
|
|
190
115
|
|
|
191
|
-
|
|
116
|
+
```javascript
|
|
117
|
+
new StickEngine({ Dirtemp: './minha-pasta' })
|
|
118
|
+
new StickEngine({ tempDir: './minha-pasta' })
|
|
119
|
+
new StickEngine({ dirTemp: './minha-pasta' })
|
|
120
|
+
```
|
|
192
121
|
|
|
193
|
-
|
|
194
|
-
2. Encodes with `libwebp` (loop, alpha, duration cap)
|
|
195
|
-
3. Shrinks quality/FPS until size is under ~1MB
|
|
196
|
-
4. Writes EXIF using the correct **node-webpmux** path for your installed version
|
|
197
|
-
- never crashes with `Using save for animations…`
|
|
198
|
-
- falls back across v1 `muxAnim` and v3 `save({ frames })`
|
|
122
|
+
Padrão: `os.tmpdir()/stickengine`
|
|
199
123
|
|
|
200
124
|
---
|
|
201
125
|
|
|
202
|
-
##
|
|
126
|
+
## 💧 Marca d'água LOGO
|
|
203
127
|
|
|
204
|
-
|
|
205
|
-
import StickEngine from '@boruto_vk7/stickengine';
|
|
128
|
+
Sua logo `logo.png` é usada automaticamente:
|
|
206
129
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
},
|
|
214
|
-
fit: 'natural',
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
await sock.sendMessage(jid, { sticker: buffer });
|
|
218
|
-
}
|
|
130
|
+
```javascript
|
|
131
|
+
{ watermark: true }
|
|
132
|
+
{ watermark: false }
|
|
133
|
+
{ watermark: './caminho/para/outra-logo.png' }
|
|
134
|
+
{ watermark: { image: './logo.png', position: 'bottom-right', size: 0.25 } }
|
|
135
|
+
{ marcaDagua: true }
|
|
219
136
|
```
|
|
220
137
|
|
|
221
|
-
|
|
138
|
+
Posições: `bottom-right`, `bottom-left`, `top-right`, `top-left`, `center`
|
|
222
139
|
|
|
223
|
-
|
|
140
|
+
---
|
|
224
141
|
|
|
225
|
-
|
|
142
|
+
## 🔄 Compatibilidade com código antigo
|
|
226
143
|
|
|
227
|
-
```
|
|
228
|
-
const
|
|
229
|
-
|
|
230
|
-
|
|
144
|
+
```javascript
|
|
145
|
+
const { sendImageAsSticker } = require('@boruto_vk7/stickengine');
|
|
146
|
+
await sendImageAsSticker(conn, jid, './foto.jpg', quoted, {
|
|
147
|
+
packname: 'Meu Pack',
|
|
148
|
+
author: 'Bot',
|
|
149
|
+
categories: ['🔥']
|
|
231
150
|
});
|
|
232
|
-
|
|
233
|
-
const sticker = await engine.build('./clip.mp4');
|
|
234
|
-
engine.clean(); // optional temp cleanup
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
### Batch queue
|
|
238
|
-
|
|
239
|
-
```ts
|
|
240
|
-
const engine = new StickEngine({ metadata: { pack: 'Batch', author: 'Bot' } });
|
|
241
|
-
engine.add('./a.jpg', './b.gif', buffer);
|
|
242
|
-
const results = await engine.start();
|
|
243
|
-
// PromiseSettledResult<string>[] → value = path when fulfilled
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
### Text sticker
|
|
247
|
-
|
|
248
|
-
```ts
|
|
249
|
-
const engine = new StickEngine();
|
|
250
|
-
const sticker = await engine.createTextSticker('ARISE', { color: 'WHITE' });
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
### Tray icon (96×96)
|
|
254
|
-
|
|
255
|
-
```ts
|
|
256
|
-
const trayPath = await engine.createTrayIcon('./logo.png');
|
|
257
|
-
```
|
|
258
|
-
|
|
259
|
-
### Events
|
|
260
|
-
|
|
261
|
-
```ts
|
|
262
|
-
engine.on('st.start', ({ index }) => {});
|
|
263
|
-
engine.on('st.info', (info) => {});
|
|
264
|
-
engine.on('st.data', ({ file, animated }) => {});
|
|
265
|
-
engine.on('st.done', (result) => {});
|
|
266
|
-
engine.on('st.error', ({ error }) => {});
|
|
267
151
|
```
|
|
268
152
|
|
|
269
153
|
---
|
|
270
154
|
|
|
271
|
-
##
|
|
155
|
+
## 📊 Testado
|
|
272
156
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
| `engine.createTextSticker(text, opts?)` | Text → sticker |
|
|
281
|
-
| `engine.createTrayIcon(input)` | Pack tray WebP |
|
|
282
|
-
| `engine.clean()` | Delete tracked temps |
|
|
283
|
-
| `getBuffer(url)` | Download helper |
|
|
157
|
+
- ✅ PNG, JPG, WEBP transparente, GIF, MP4, WEBM
|
|
158
|
+
- ✅ Buffer, Path local, URL https, Data URI base64, Base64 puro
|
|
159
|
+
- ✅ Dirtemp custom
|
|
160
|
+
- ✅ Watermark logo e texto
|
|
161
|
+
- ✅ Fit natural, cover, contain, fill, none
|
|
162
|
+
- ✅ ESM + CJS dual package
|
|
163
|
+
- ✅ Foto real com logo Lagos Solutions no canto e no centro
|
|
284
164
|
|
|
285
165
|
---
|
|
286
166
|
|
|
287
|
-
##
|
|
288
|
-
|
|
289
|
-
- TypeScript source, dual **ESM + CJS** emit
|
|
290
|
-
- Strict typing for options and results
|
|
291
|
-
- Zero config for the happy path
|
|
292
|
-
- Designed for long-running bot processes
|
|
167
|
+
## 📄 Licença
|
|
293
168
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
## Author
|
|
297
|
-
|
|
298
|
-
**Borutovk7** — creator of StickEngine.
|
|
299
|
-
|
|
300
|
-
If you ship stickers at scale, this is the engine you want under the hood.
|
|
301
|
-
|
|
302
|
-
---
|
|
169
|
+
MIT - Lagos Solutions
|
|
303
170
|
|
|
304
|
-
|
|
171
|
+

|
|
305
172
|
|
|
306
|
-
|
|
173
|
+
**SOLUÇÕES INTELIGENTES. RESULTADOS REAIS.**
|