@boruto_vk7/stickengine 1.1.1 → 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 CHANGED
@@ -1,300 +1,233 @@
1
- # StickEngine
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
- **Professional WhatsApp sticker engine for Node.js.**
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
- [![npm](https://img.shields.io/npm/v/@boruto_vk7/stickengine.svg)](https://www.npmjs.com/package/@boruto_vk7/stickengine)
8
- [![Node](https://img.shields.io/node/v/@boruto_vk7/stickengine.svg)](https://nodejs.org)
9
- [![License: MIT](https://img.shields.io/badge/License-MIT-red.svg)](./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
- ## Requirements
30
+ ## ✨ Funcionalidades
34
31
 
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`)
38
-
39
- ```bash
40
- # Debian / Ubuntu
41
- sudo apt install ffmpeg
42
-
43
- # macOS
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
- ## Quick start
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('./photo.jpg', {
50
+ const sticker = await StickEngine.create('./foto.jpg', {
51
+ Dirtemp: './temp',
52
+ watermark: true,
57
53
  metadata: {
58
- pack: 'StickEngine',
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
- ```js
71
- const StickEngine = require('@boruto_vk7/stickengine').default;
72
-
73
- const sticker = await StickEngine.create(buffer, {
74
- metadata: { pack: 'My Pack', author: 'Bot' },
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
- ### Even shorter
75
+ ### Com marca d'água
79
76
 
80
- ```ts
81
- const buf = await StickEngine.toBuffer(media, {
82
- metadata: { pack: 'Waguri', author: 'Evolution' },
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: 'cover'`** — the media **fills the full 512×512 square** (center-crop), so stickers look like normal WhatsApp stickers instead of a small image floating in empty space.
93
83
 
94
- ```ts
95
- await StickEngine.create(input, {
96
- fit: 'cover', // default full sticker square (crop edges if needed)
97
- // fit: 'contain', // whole image + transparent margins (no black bars)
98
- // fit: 'fill', // stretch (distorts)
99
- // fit: 'none', // only shrink if larger than 512; no pad
84
+ await StickEngine.create('./imagem.png', {
85
+ watermark: 'MEU TEXTO CUSTOM',
86
+ metadata: { pack: 'Pack', author: 'Author' }
100
87
  });
101
- ```
102
-
103
- | `fit` | Look |
104
- |-------|------|
105
- | `cover` (default) | Edge-to-edge sticker, may crop top/bottom or sides |
106
- | `contain` | Full image visible, transparent padding (never black) |
107
- | `fill` | Stretched to square |
108
- | `none` | Original aspect, max 512 on the long side |
109
88
 
110
- `contain` always pads with **true alpha** (`format=rgba` + `pad=…:black@0`) — never opaque black bars.
111
-
112
- ---
89
+ await StickEngine.create('./imagem.png', {
90
+ watermark: { text: 'LAGOS', position: 'center', margin: 20 },
91
+ metadata: { pack: 'Pack', author: 'Author' }
92
+ });
113
93
 
114
- ## Result object
115
-
116
- ```ts
117
- interface StickResult {
118
- path: string; // absolute path to .webp
119
- buffer: Buffer; // send this to WhatsApp
120
- base64: string; // raw base64 (no data: prefix)
121
- animated: boolean;
122
- width: number;
123
- height: number;
124
- size: number; // bytes
125
- }
94
+ await StickEngine.create('./imagem.png', {
95
+ watermark: false,
96
+ metadata: { pack: 'Sem marca', author: 'Bot' }
97
+ });
126
98
  ```
127
99
 
128
100
  ---
129
101
 
130
- ## Options
102
+ ## 🎨 Modos de Enquadramento
131
103
 
132
- ```ts
133
- await StickEngine.create(input, {
134
- metadata: {
135
- pack: 'Pack name shown in WhatsApp',
136
- author: 'Publisher name',
137
- emojis: ['🔥', '✨'],
138
- id: 'optional-stable-pack-id',
139
- },
140
-
141
- fit: 'cover', // cover | contain | fill | none
142
- fps: 15, // animated FPS
143
- quality: 80, // 1–100 (auto-reduced if anim > 1MB)
144
- maxDuration: 6, // seconds (WA-friendly)
145
-
146
- edit: {
147
- // static images only
148
- circle: true,
149
- greyscale: false,
150
- sepia: false,
151
- blur: 0,
152
- brightness: 0, // -1 … 1
153
- contrast: 0, // -1 … 1
154
- text: {
155
- content: 'TOP',
156
- color: 'WHITE',
157
- stroke: true, // outlined caption
158
- },
159
- },
160
-
161
- // transparent: 'REMOVE_BG_API_KEY', // static only (remove.bg)
162
- autoClean: false,
163
- tempDir: './tmp_stickengine',
164
- });
104
+ ```javascript
105
+ await StickEngine.create(input, { fit: 'natural' });
165
106
  ```
166
107
 
167
- | Option | Default | Description |
168
- |--------|---------|-------------|
169
- | `metadata.pack` | `StickEngine` | Sticker pack title |
170
- | `metadata.author` | `Borutovk7` | Pack publisher |
171
- | `fit` | `cover` | Canvas fit `cover` fills the sticker square |
172
- | `fps` | `15` | Animated frame rate |
173
- | `quality` | `80` | WebP quality; auto-lowers for large animations |
174
- | `maxDuration` | `6` | Trim long videos/GIFs |
175
- | `edit` | `false` | Jimp filters (static only) |
176
- | `transparent` | `false` | remove.bg API key / key list |
177
- | `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` | diminui se maior que 512, nunca aumenta |
178
115
 
179
116
  ---
180
117
 
181
- ## Animated stickers & EXIF
118
+ ## 📁 Dirtemp Personalizado
182
119
 
183
- WhatsApp animated stickers are **animated WebP** with EXIF pack metadata.
120
+ Aceita qualquer alias:
184
121
 
185
- StickEngine:
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
+ ```
186
128
 
187
- 1. Detects GIF / MP4 / animated WebP
188
- 2. Encodes with `libwebp` (loop, alpha, duration cap)
189
- 3. Shrinks quality/FPS until size is under ~1MB
190
- 4. Writes EXIF using the correct **node-webpmux** path for your installed version
191
- - never crashes with `Using save for animations…`
192
- - falls back across v1 `muxAnim` and v3 `save({ frames })`
129
+ Padrão: `os.tmpdir()/stickengine`
193
130
 
194
131
  ---
195
132
 
196
- ## Baileys
197
-
198
- ```ts
199
- import StickEngine from '@boruto_vk7/stickengine';
133
+ ## 💧 Marca d'água
200
134
 
201
- export async function sendSticker(sock: any, jid: string, media: Buffer) {
202
- const { buffer } = await StickEngine.create(media, {
203
- metadata: {
204
- pack: 'Waguri Evolution',
205
- author: 'Borutovk7',
206
- emojis: ['💜'],
207
- },
208
- fit: 'cover',
209
- });
210
-
211
- await sock.sendMessage(jid, { sticker: buffer });
212
- }
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 }
213
142
  ```
214
143
 
144
+ Posições: `bottom-right`, `bottom-left`, `top-right`, `top-left`, `center`
145
+
215
146
  ---
216
147
 
217
- ## More APIs
148
+ ## 🔄 Compatibilidade com código antigo
218
149
 
219
- ### Instance pipeline
150
+ ### rename.js antigo
151
+ ```javascript
152
+ const { sendImageAsSticker, sendVideoAsSticker } = require('@boruto_vk7/stickengine');
220
153
 
221
- ```ts
222
- const engine = new StickEngine({
223
- metadata: { pack: 'Studio', author: 'You' },
224
- fit: 'cover',
154
+ await sendImageAsSticker(conn, jid, './foto.jpg', quoted, {
155
+ packname: 'Meu Pack',
156
+ author: 'Bot',
157
+ categories: ['🔥']
225
158
  });
226
-
227
- const sticker = await engine.build('./clip.mp4');
228
- engine.clean(); // optional temp cleanup
229
- ```
230
-
231
- ### Batch queue
232
-
233
- ```ts
234
- const engine = new StickEngine({ metadata: { pack: 'Batch', author: 'Bot' } });
235
- engine.add('./a.jpg', './b.gif', buffer);
236
- const results = await engine.start();
237
- // PromiseSettledResult<string>[] → value = path when fulfilled
238
159
  ```
239
160
 
240
- ### Text sticker
161
+ ### exif.js antigo
162
+ ```javascript
163
+ const { imageToWebp, writeExifImg } = require('@boruto_vk7/stickengine');
241
164
 
242
- ```ts
243
- const engine = new StickEngine();
244
- const sticker = await engine.createTextSticker('ARISE', { color: 'WHITE' });
165
+ const webpBuffer = await imageToWebp(buffer);
166
+ const path = await writeExifImg(buffer, { packname: 'Pack', author: 'Author' });
245
167
  ```
246
168
 
247
- ### Tray icon (96×96)
248
-
249
- ```ts
250
- const trayPath = await engine.createTrayIcon('./logo.png');
251
- ```
252
-
253
- ### Events
254
-
255
- ```ts
256
- engine.on('st.start', ({ index }) => {});
257
- engine.on('st.info', (info) => {});
258
- engine.on('st.data', ({ file, animated }) => {});
259
- engine.on('st.done', (result) => {});
260
- engine.on('st.error', ({ error }) => {});
261
- ```
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`
262
175
 
263
176
  ---
264
177
 
265
- ## API surface
178
+ ## 📊 Tipos de Figurinha Testados
266
179
 
267
- | Method | Description |
268
- |--------|-------------|
269
- | `StickEngine.create(input, opts?)` | One-shot `StickResult` |
270
- | `StickEngine.toBuffer(input, opts?)` | One-shot `Buffer` |
271
- | `StickEngine.toBase64String(input, opts?)` | One-shot base64 |
272
- | `engine.build(input)` | Instance one-shot |
273
- | `engine.addFile` / `engine.add` / `engine.start` | Batch queue |
274
- | `engine.createTextSticker(text, opts?)` | Text → sticker |
275
- | `engine.createTrayIcon(input)` | Pack tray WebP |
276
- | `engine.clean()` | Delete tracked temps |
277
- | `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
278
190
 
279
191
  ---
280
192
 
281
- ## Project standards
193
+ ## ⚙️ Opções Completas
282
194
 
283
- - TypeScript source, dual **ESM + CJS** emit
284
- - Strict typing for options and results
285
- - Zero config for the happy path
286
- - Designed for long-running bot processes
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
+ ```
287
212
 
288
213
  ---
289
214
 
290
- ## Author
215
+ ## 🧪 Testes
291
216
 
292
- **Borutovk7** — creator of StickEngine.
217
+ ```bash
218
+ npm run build
219
+ node test_all_stickers.mjs
220
+ ```
293
221
 
294
- If you ship stickers at scale, this is the engine you want under the hood.
222
+ Todos os testes passaram com FFmpeg incluso.
295
223
 
296
224
  ---
297
225
 
298
- ## License
226
+ ## 📄 Licença
227
+
228
+ MIT - Lagos Solutions
299
229
 
300
- MIT © Borutovk7
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>