@boruto_vk7/stickengine 0.0.6 → 1.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/LICENSE +18 -12
- package/README.md +162 -83
- package/dist/cjs/StickEngine.js +616 -0
- package/dist/cjs/StickEngine.js.map +1 -0
- package/dist/cjs/emror.jpg +0 -0
- package/dist/cjs/index.js +9 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/esm/StickEngine.js +576 -0
- package/dist/esm/StickEngine.js.map +1 -0
- package/dist/esm/emror.jpg +0 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/types/StickEngine.d.ts +137 -0
- package/dist/types/StickEngine.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/package.json +55 -32
- package/assets/preview_animated.png +0 -0
- package/assets/preview_sepia.png +0 -0
- package/dist/StickEngine.d.ts +0 -72
- package/dist/StickEngine.js +0 -369
package/LICENSE
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
|
|
1
|
+
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2026
|
|
3
|
+
Copyright (c) 2026 Borutovk7
|
|
4
4
|
|
|
5
|
-
Permission
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
OR
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,130 +1,209 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @boruto_vk7/stickengine
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Simple **WhatsApp sticker** engine for Node.js.
|
|
4
|
+
|
|
5
|
+
- Static **and animated** WebP stickers
|
|
6
|
+
- Pack name / author EXIF (WhatsApp metadata)
|
|
7
|
+
- One-line API: `StickEngine.create()`
|
|
8
|
+
- **ESM + CommonJS**
|
|
9
|
+
- GIF / MP4 / WebP / PNG / JPG
|
|
10
|
+
|
|
11
|
+
> Requires **ffmpeg** + **ffprobe** on your system.
|
|
4
12
|
|
|
5
13
|
---
|
|
6
14
|
|
|
7
|
-
##
|
|
15
|
+
## Install
|
|
8
16
|
|
|
9
|
-
### Instalação
|
|
10
17
|
```bash
|
|
11
18
|
npm install @boruto_vk7/stickengine
|
|
12
19
|
```
|
|
13
|
-
> **Requisito**: Tenha o `ffmpeg` instalado no seu sistema.
|
|
14
|
-
|
|
15
|
-
### Suporte Híbrido
|
|
16
|
-
O módulo funciona tanto com **ESM** quanto **CommonJS**:
|
|
17
|
-
- **ESM**: `import StickEngine from '@boruto_vk7/stickengine';`
|
|
18
|
-
- **CJS**: `const StickEngine = require('@boruto_vk7/stickengine').default;`
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
engine.addFile('./foto.jpg'); // Adiciona a imagem
|
|
25
|
-
const results = await engine.start(); // Inicia o processamento
|
|
26
|
-
console.log('Sticker salvo em:', results[0].value);
|
|
21
|
+
```bash
|
|
22
|
+
# system dependency
|
|
23
|
+
sudo apt install ffmpeg # Debian/Ubuntu
|
|
24
|
+
# brew install ffmpeg # macOS
|
|
27
25
|
```
|
|
28
26
|
|
|
29
27
|
---
|
|
30
28
|
|
|
31
|
-
##
|
|
29
|
+
## Quick start (easiest)
|
|
32
30
|
|
|
33
|
-
###
|
|
34
|
-
|
|
35
|
-
```
|
|
36
|
-
|
|
31
|
+
### ESM / TypeScript
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import StickEngine from '@boruto_vk7/stickengine';
|
|
35
|
+
|
|
36
|
+
// path | URL | Buffer
|
|
37
|
+
const sticker = await StickEngine.create('./cat.gif', {
|
|
37
38
|
metadata: {
|
|
38
|
-
pack: '
|
|
39
|
-
author: '
|
|
40
|
-
|
|
39
|
+
pack: 'My Pack',
|
|
40
|
+
author: 'Boruto',
|
|
41
|
+
emojis: ['😺'],
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
console.log(sticker.path); // /tmp/.../sticker_xxx.webp
|
|
46
|
+
console.log(sticker.buffer); // Buffer — send this to WhatsApp
|
|
47
|
+
console.log(sticker.base64); // base64 string
|
|
48
|
+
console.log(sticker.animated);// true/false
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### CommonJS
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
const StickEngine = require('@boruto_vk7/stickengine').default;
|
|
55
|
+
// or: const { StickEngine } = require('@boruto_vk7/stickengine');
|
|
56
|
+
|
|
57
|
+
const sticker = await StickEngine.create('./photo.jpg', {
|
|
58
|
+
metadata: { pack: 'Cool Pack', author: 'Me' },
|
|
41
59
|
});
|
|
42
60
|
```
|
|
43
61
|
|
|
44
|
-
###
|
|
45
|
-
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
62
|
+
### Buffer only (bots)
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
const buf = await StickEngine.toBuffer(imageBuffer, {
|
|
66
|
+
metadata: { pack: 'Bot Pack', author: 'Waguri' },
|
|
67
|
+
});
|
|
68
|
+
// send buf as sticker
|
|
50
69
|
```
|
|
51
70
|
|
|
52
71
|
---
|
|
53
72
|
|
|
54
|
-
##
|
|
73
|
+
## Baileys example
|
|
55
74
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
75
|
+
```ts
|
|
76
|
+
import StickEngine from '@boruto_vk7/stickengine';
|
|
77
|
+
|
|
78
|
+
const sticker = await StickEngine.create(mediaBuffer, {
|
|
79
|
+
metadata: { pack: 'Waguri', author: 'Bot' },
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
await sock.sendMessage(jid, {
|
|
83
|
+
sticker: sticker.buffer,
|
|
65
84
|
});
|
|
66
85
|
```
|
|
67
86
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## Options
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
await StickEngine.create(input, {
|
|
93
|
+
metadata: {
|
|
94
|
+
pack: 'Pack name',
|
|
95
|
+
author: 'Author',
|
|
96
|
+
emojis: ['🔥'],
|
|
97
|
+
id: 'optional-pack-id',
|
|
98
|
+
},
|
|
99
|
+
fps: 15, // animated FPS (default 15)
|
|
100
|
+
quality: 75, // animated quality 1–100
|
|
101
|
+
maxDuration: 6, // seconds (WhatsApp-friendly)
|
|
102
|
+
edit: { // static images only
|
|
103
|
+
circle: true,
|
|
104
|
+
sepia: true,
|
|
105
|
+
brightness: 0.1,
|
|
106
|
+
text: { content: 'LOL', color: 'WHITE', stroke: true },
|
|
107
|
+
},
|
|
108
|
+
// transparent: 'REMOVE_BG_API_KEY', // static only
|
|
109
|
+
autoClean: false,
|
|
110
|
+
tempDir: './tmp_stickengine',
|
|
79
111
|
});
|
|
80
112
|
```
|
|
81
113
|
|
|
114
|
+
| Option | Default | Notes |
|
|
115
|
+
|--------|---------|--------|
|
|
116
|
+
| `metadata.pack` | `StickEngine` | Pack title in WhatsApp |
|
|
117
|
+
| `metadata.author` | `Borutovk7` | Publisher |
|
|
118
|
+
| `fps` | `15` | Animated stickers |
|
|
119
|
+
| `quality` | `75` | Auto-lowers if file > 1MB |
|
|
120
|
+
| `maxDuration` | `6` | Cuts longer videos |
|
|
121
|
+
| `edit` | `false` | Jimp filters (static only) |
|
|
122
|
+
| `transparent` | `false` | remove.bg API key |
|
|
123
|
+
| `autoClean` | `false` | Call `.clean()` yourself if needed |
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## Result object
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
interface StickResult {
|
|
131
|
+
path: string; // absolute .webp path
|
|
132
|
+
buffer: Buffer; // file bytes
|
|
133
|
+
base64: string; // no data: prefix
|
|
134
|
+
animated: boolean;
|
|
135
|
+
width: number;
|
|
136
|
+
height: number;
|
|
137
|
+
size: number; // bytes
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
82
141
|
---
|
|
83
142
|
|
|
84
|
-
##
|
|
143
|
+
## More features
|
|
85
144
|
|
|
86
|
-
###
|
|
87
|
-
|
|
88
|
-
```
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
background: 0x00000000 // Transparente
|
|
145
|
+
### Text sticker
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
const engine = new StickEngine({
|
|
149
|
+
metadata: { pack: 'TP', author: 'Me' },
|
|
92
150
|
});
|
|
151
|
+
const sticker = await engine.createTextSticker('TOP!', { color: 'WHITE' });
|
|
93
152
|
```
|
|
94
153
|
|
|
95
|
-
###
|
|
96
|
-
|
|
97
|
-
```
|
|
154
|
+
### Tray icon (96×96)
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
const engine = new StickEngine();
|
|
98
158
|
const trayPath = await engine.createTrayIcon('./logo.png');
|
|
99
159
|
```
|
|
100
160
|
|
|
101
|
-
###
|
|
102
|
-
|
|
161
|
+
### Batch queue
|
|
162
|
+
|
|
163
|
+
```ts
|
|
164
|
+
const engine = new StickEngine({ metadata: { pack: 'Batch', author: 'Me' } });
|
|
165
|
+
engine.add('./a.jpg', './b.gif', buffer);
|
|
166
|
+
const results = await engine.start();
|
|
167
|
+
// results[i].status === 'fulfilled' → results[i].value is the path
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Events
|
|
171
|
+
|
|
172
|
+
```ts
|
|
173
|
+
engine.on('st.start', ({ index }) => console.log('start', index));
|
|
174
|
+
engine.on('st.info', (info) => console.log(info));
|
|
175
|
+
engine.on('st.data', ({ file, animated }) => console.log(file, animated));
|
|
176
|
+
engine.on('st.error', ({ error }) => console.error(error));
|
|
177
|
+
engine.on('st.done', (result) => console.log(result.size));
|
|
178
|
+
```
|
|
103
179
|
|
|
104
180
|
---
|
|
105
181
|
|
|
106
|
-
##
|
|
182
|
+
## Animated WebP EXIF fix
|
|
183
|
+
|
|
184
|
+
Older builds called `img.save()` on **animated** stickers, which throws:
|
|
185
|
+
|
|
186
|
+
```text
|
|
187
|
+
Using `save` for animations is not currently supported. Use `muxAnim` instead
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
This version:
|
|
191
|
+
|
|
192
|
+
1. Detects animation via `hasAnim` / `frameCount` / `frames`
|
|
193
|
+
2. Saves animated WebP with **`muxAnim({ path, exif: true, ... })`**
|
|
194
|
+
3. Falls back to `muxAnim` if `save()` still rejects
|
|
195
|
+
|
|
196
|
+
Static stickers still use `save()`.
|
|
197
|
+
|
|
198
|
+
---
|
|
107
199
|
|
|
108
|
-
|
|
109
|
-
| Propriedade | Tipo | Padrão | Descrição |
|
|
110
|
-
| :--- | :--- | :--- | :--- |
|
|
111
|
-
| `quality` | `Number` | `80` | Qualidade do WebP (1-100). |
|
|
112
|
-
| `fps` | `Number` | `15` | Frames por segundo para animados. |
|
|
113
|
-
| `autoClean` | `Boolean` | `true` | Apaga temporários automaticamente. |
|
|
200
|
+
## Requirements
|
|
114
201
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
| :--- | :--- |
|
|
118
|
-
| `circle` | Ativa o recorte circular. |
|
|
119
|
-
| `brightness` | Ajusta o brilho (-1 a 1). |
|
|
120
|
-
| `contrast` | Ajusta o contraste (-1 a 1). |
|
|
121
|
-
| `blur` | Aplica desfoque. |
|
|
122
|
-
| `text.stroke` | Adiciona contorno ao texto. |
|
|
202
|
+
- Node.js **≥ 18**
|
|
203
|
+
- `ffmpeg` + `ffprobe` in `PATH`
|
|
123
204
|
|
|
124
205
|
---
|
|
125
206
|
|
|
126
|
-
##
|
|
127
|
-
Desenvolvido por **Borutovk7**.
|
|
207
|
+
## License
|
|
128
208
|
|
|
129
|
-
|
|
130
|
-
ISC
|
|
209
|
+
MIT · [Borutovk7](https://github.com/Borutovk7)
|