@boruto_vk7/stickengine 1.2.0 → 2.0.0
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 +152 -225
- 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/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/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/package.json +20 -38
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -1,306 +1,233 @@
|
|
|
1
|
-
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src="./logo.png" width="400" alt="Lagos Solutions"/>
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h1 align="center">StickEngine - Lagos Solutions</h1>
|
|
6
|
+
<p align="center">
|
|
7
|
+
<strong>Motor profissional de figurinhas para WhatsApp</strong><br>
|
|
8
|
+
Estático e animado, com EXIF, marca d'água e suporte total ESM + CJS + TypeScript
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<p align="center">
|
|
12
|
+
<img src="https://img.shields.io/npm/v/@boruto_vk7/stickengine?style=flat-square&color=7c3aed" alt="npm version"/>
|
|
13
|
+
<img src="https://img.shields.io/node/v/@boruto_vk7/stickengine?style=flat-square&color=7c3aed" alt="node version"/>
|
|
14
|
+
<img src="https://img.shields.io/badge/License-MIT-7c3aed?style=flat-square" alt="license"/>
|
|
15
|
+
<img src="https://img.shields.io/badge/Lagos-Solutions-7c3aed?style=flat-square" alt="lagos"/>
|
|
16
|
+
</p>
|
|
2
17
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Build production-ready **static and animated** stickers with correct EXIF pack metadata, transparent framing (no black bars), and a one-line API.
|
|
18
|
+
---
|
|
6
19
|
|
|
7
|
-
|
|
8
|
-
[](https://nodejs.org)
|
|
9
|
-
[](./LICENSE)
|
|
20
|
+
## 🚀 Instalação
|
|
10
21
|
|
|
11
22
|
```bash
|
|
12
23
|
npm install @boruto_vk7/stickengine
|
|
13
24
|
```
|
|
14
25
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
## Why StickEngine
|
|
18
|
-
|
|
19
|
-
Most sticker helpers break on the details that matter in real bots:
|
|
20
|
-
|
|
21
|
-
| Problem in typical libs | StickEngine |
|
|
22
|
-
|-------------------------|-------------|
|
|
23
|
-
| Black bars on portrait/landscape media | **True transparent pad** (`format=rgba` → `pad=…:black@0`) |
|
|
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)** |
|
|
28
|
-
|
|
29
|
-
Built for Baileys, Evolution, Venom, whatsapp-web.js and any stack that sends a WebP buffer.
|
|
26
|
+
FFmpeg já incluso via `@ffmpeg-installer/ffmpeg`. Não precisa instalar manualmente.
|
|
30
27
|
|
|
31
28
|
---
|
|
32
29
|
|
|
33
|
-
##
|
|
30
|
+
## ✨ Funcionalidades
|
|
34
31
|
|
|
35
|
-
- **
|
|
36
|
-
- **
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
brew install ffmpeg
|
|
45
|
-
```
|
|
32
|
+
- ✅ **Todos os tipos de entrada:** Buffer, caminho local, URL https, data URI base64, base64 puro
|
|
33
|
+
- ✅ **Todos os tipos de figurinha:** JPG, PNG, WEBP estático, GIF animado, MP4, WEBM
|
|
34
|
+
- ✅ **5 modos de enquadramento:** `natural` (padrão WA), `cover`, `contain`, `fill`, `none`
|
|
35
|
+
- ✅ **EXIF com pack e autor:** Compatível com node-webpmux v1 e v3
|
|
36
|
+
- ✅ **Auto shrink:** Figurinhas animadas sempre abaixo de 1MB
|
|
37
|
+
- ✅ **Dirtemp custom:** `Dirtemp`, `tempDir`, `dirTemp` - qualquer alias funciona
|
|
38
|
+
- ✅ **Marca d'água:** `watermark: true/false` ou texto customizado
|
|
39
|
+
- ✅ **Compatível:** ESM `import`, CJS `require()`, TypeScript `NodeNext` e `CommonJS`
|
|
40
|
+
- ✅ **APIs antigas:** `sendImageAsSticker`, `imageToWebp`, `writeExifImg` ainda funcionam
|
|
46
41
|
|
|
47
42
|
---
|
|
48
43
|
|
|
49
|
-
##
|
|
44
|
+
## 📦 Uso Rápido
|
|
50
45
|
|
|
51
46
|
### ESM / TypeScript
|
|
52
|
-
|
|
53
|
-
```ts
|
|
47
|
+
```javascript
|
|
54
48
|
import StickEngine from '@boruto_vk7/stickengine';
|
|
55
49
|
|
|
56
|
-
const sticker = await StickEngine.create('./
|
|
50
|
+
const sticker = await StickEngine.create('./foto.jpg', {
|
|
51
|
+
Dirtemp: './temp',
|
|
52
|
+
watermark: true,
|
|
57
53
|
metadata: {
|
|
58
|
-
pack: '
|
|
54
|
+
pack: 'Lagos Solutions',
|
|
59
55
|
author: 'Borutovk7',
|
|
60
|
-
emojis: ['
|
|
61
|
-
}
|
|
56
|
+
emojis: ['🔥']
|
|
57
|
+
}
|
|
62
58
|
});
|
|
63
59
|
|
|
64
|
-
// WhatsApp-ready WebP
|
|
65
60
|
await sock.sendMessage(jid, { sticker: sticker.buffer });
|
|
66
61
|
```
|
|
67
62
|
|
|
68
63
|
### CommonJS
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
```javascript
|
|
65
|
+
const StickEngine = require('@boruto_vk7/stickengine');
|
|
66
|
+
|
|
67
|
+
const buffer = await StickEngine.toBuffer('./video.mp4', {
|
|
68
|
+
Dirtemp: '/tmp/meus-stickers',
|
|
69
|
+
watermark: false,
|
|
70
|
+
fit: 'natural',
|
|
71
|
+
metadata: { pack: 'Meu Pack', author: 'Bot' }
|
|
75
72
|
});
|
|
76
73
|
```
|
|
77
74
|
|
|
78
|
-
###
|
|
75
|
+
### Com marca d'água
|
|
79
76
|
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
```javascript
|
|
78
|
+
await StickEngine.create('./imagem.png', {
|
|
79
|
+
Dirtemp: './temp',
|
|
80
|
+
watermark: true,
|
|
81
|
+
metadata: { pack: 'Lagos', author: 'Solutions' }
|
|
83
82
|
});
|
|
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
83
|
|
|
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
|
|
84
|
+
await StickEngine.create('./imagem.png', {
|
|
85
|
+
watermark: 'MEU TEXTO CUSTOM',
|
|
86
|
+
metadata: { pack: 'Pack', author: 'Author' }
|
|
107
87
|
});
|
|
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
88
|
|
|
118
|
-
|
|
89
|
+
await StickEngine.create('./imagem.png', {
|
|
90
|
+
watermark: { text: 'LAGOS', position: 'center', margin: 20 },
|
|
91
|
+
metadata: { pack: 'Pack', author: 'Author' }
|
|
92
|
+
});
|
|
119
93
|
|
|
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
|
-
}
|
|
94
|
+
await StickEngine.create('./imagem.png', {
|
|
95
|
+
watermark: false,
|
|
96
|
+
metadata: { pack: 'Sem marca', author: 'Bot' }
|
|
97
|
+
});
|
|
132
98
|
```
|
|
133
99
|
|
|
134
100
|
---
|
|
135
101
|
|
|
136
|
-
##
|
|
102
|
+
## 🎨 Modos de Enquadramento
|
|
137
103
|
|
|
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
|
-
});
|
|
104
|
+
```javascript
|
|
105
|
+
await StickEngine.create(input, { fit: 'natural' });
|
|
171
106
|
```
|
|
172
107
|
|
|
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 |
|
|
108
|
+
| Fit | Resultado |
|
|
109
|
+
|-----|-----------|
|
|
110
|
+
| `natural` (padrão) | Mantém proporção, lado maior = 512px - visual real do WhatsApp |
|
|
111
|
+
| `cover` | Força 512x512 quadrado com corte central |
|
|
112
|
+
| `contain` | Encaixa dentro de 512x512 com fundo transparente |
|
|
113
|
+
| `fill` | Estica para 512x512 |
|
|
114
|
+
| `none` | Só diminui se maior que 512, nunca aumenta |
|
|
184
115
|
|
|
185
116
|
---
|
|
186
117
|
|
|
187
|
-
##
|
|
118
|
+
## 📁 Dirtemp Personalizado
|
|
188
119
|
|
|
189
|
-
|
|
120
|
+
Aceita qualquer alias:
|
|
190
121
|
|
|
191
|
-
|
|
122
|
+
```javascript
|
|
123
|
+
new StickEngine({ Dirtemp: './minha-pasta' })
|
|
124
|
+
new StickEngine({ tempDir: './minha-pasta' })
|
|
125
|
+
new StickEngine({ dirTemp: './minha-pasta' })
|
|
126
|
+
new StickEngine({ DirTemp: './minha-pasta' })
|
|
127
|
+
```
|
|
192
128
|
|
|
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 })`
|
|
129
|
+
Padrão: `os.tmpdir()/stickengine`
|
|
199
130
|
|
|
200
131
|
---
|
|
201
132
|
|
|
202
|
-
##
|
|
133
|
+
## 💧 Marca d'água
|
|
203
134
|
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
author: 'Borutovk7',
|
|
212
|
-
emojis: ['💜'],
|
|
213
|
-
},
|
|
214
|
-
fit: 'natural',
|
|
215
|
-
});
|
|
216
|
-
|
|
217
|
-
await sock.sendMessage(jid, { sticker: buffer });
|
|
218
|
-
}
|
|
135
|
+
```javascript
|
|
136
|
+
{ watermark: true }
|
|
137
|
+
{ watermark: false }
|
|
138
|
+
{ watermark: 'Texto Custom' }
|
|
139
|
+
{ watermark: { text: 'Lagos', position: 'bottom-right' } }
|
|
140
|
+
{ marcaDagua: true }
|
|
141
|
+
{ marca_agua: true }
|
|
219
142
|
```
|
|
220
143
|
|
|
144
|
+
Posições: `bottom-right`, `bottom-left`, `top-right`, `top-left`, `center`
|
|
145
|
+
|
|
221
146
|
---
|
|
222
147
|
|
|
223
|
-
##
|
|
148
|
+
## 🔄 Compatibilidade com código antigo
|
|
224
149
|
|
|
225
|
-
###
|
|
150
|
+
### rename.js antigo
|
|
151
|
+
```javascript
|
|
152
|
+
const { sendImageAsSticker, sendVideoAsSticker } = require('@boruto_vk7/stickengine');
|
|
226
153
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
154
|
+
await sendImageAsSticker(conn, jid, './foto.jpg', quoted, {
|
|
155
|
+
packname: 'Meu Pack',
|
|
156
|
+
author: 'Bot',
|
|
157
|
+
categories: ['🔥']
|
|
231
158
|
});
|
|
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
159
|
```
|
|
245
160
|
|
|
246
|
-
###
|
|
161
|
+
### exif.js antigo
|
|
162
|
+
```javascript
|
|
163
|
+
const { imageToWebp, writeExifImg } = require('@boruto_vk7/stickengine');
|
|
247
164
|
|
|
248
|
-
|
|
249
|
-
const
|
|
250
|
-
const sticker = await engine.createTextSticker('ARISE', { color: 'WHITE' });
|
|
165
|
+
const webpBuffer = await imageToWebp(buffer);
|
|
166
|
+
const path = await writeExifImg(buffer, { packname: 'Pack', author: 'Author' });
|
|
251
167
|
```
|
|
252
168
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
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
|
-
```
|
|
169
|
+
Todos os inputs antigos funcionam:
|
|
170
|
+
- `Buffer`
|
|
171
|
+
- `data:image/png;base64,...`
|
|
172
|
+
- `https://exemplo.com/foto.jpg`
|
|
173
|
+
- `./caminho/local.jpg`
|
|
174
|
+
- `base64 puro`
|
|
268
175
|
|
|
269
176
|
---
|
|
270
177
|
|
|
271
|
-
##
|
|
178
|
+
## 📊 Tipos de Figurinha Testados
|
|
272
179
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
| `getBuffer(url)` | Download helper |
|
|
180
|
+
- ✅ PNG estático 512x512
|
|
181
|
+
- ✅ JPG 800x600
|
|
182
|
+
- ✅ Retrato 1080x1920 -> 288x512 natural
|
|
183
|
+
- ✅ Paisagem 1920x1080 -> 512x288 natural
|
|
184
|
+
- ✅ PNG transparente
|
|
185
|
+
- ✅ Buffer direto
|
|
186
|
+
- ✅ Path local
|
|
187
|
+
- ✅ Data URI base64
|
|
188
|
+
- ✅ Base64 puro sem prefixo
|
|
189
|
+
- ✅ URL remota com fallback emror.jpg
|
|
284
190
|
|
|
285
191
|
---
|
|
286
192
|
|
|
287
|
-
##
|
|
193
|
+
## ⚙️ Opções Completas
|
|
288
194
|
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
195
|
+
```javascript
|
|
196
|
+
await StickEngine.create(input, {
|
|
197
|
+
Dirtemp: './temp',
|
|
198
|
+
tempDir: './temp',
|
|
199
|
+
watermark: true,
|
|
200
|
+
fit: 'natural',
|
|
201
|
+
fps: 15,
|
|
202
|
+
quality: 80,
|
|
203
|
+
maxDuration: 6,
|
|
204
|
+
metadata: {
|
|
205
|
+
pack: 'Lagos Solutions',
|
|
206
|
+
author: 'Borutovk7',
|
|
207
|
+
emojis: ['✨', '🔥'],
|
|
208
|
+
id: 'meu-pack-id'
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
```
|
|
293
212
|
|
|
294
213
|
---
|
|
295
214
|
|
|
296
|
-
##
|
|
215
|
+
## 🧪 Testes
|
|
297
216
|
|
|
298
|
-
|
|
217
|
+
```bash
|
|
218
|
+
npm run build
|
|
219
|
+
node test_all_stickers.mjs
|
|
220
|
+
```
|
|
299
221
|
|
|
300
|
-
|
|
222
|
+
Todos os testes passaram com FFmpeg incluso.
|
|
301
223
|
|
|
302
224
|
---
|
|
303
225
|
|
|
304
|
-
##
|
|
226
|
+
## 📄 Licença
|
|
227
|
+
|
|
228
|
+
MIT - Lagos Solutions
|
|
305
229
|
|
|
306
|
-
|
|
230
|
+
<p align="center">
|
|
231
|
+
<strong>SOLUÇÕES INTELIGENTES. RESULTADOS REAIS.</strong><br>
|
|
232
|
+
<img src="./logo.png" width="200" alt="Lagos Solutions"/>
|
|
233
|
+
</p>
|