@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 CHANGED
@@ -1,15 +1,21 @@
1
- ISC License
1
+ MIT License
2
2
 
3
- Copyright (c) 2026, Borutovk7 <https://github.com/Borutovk7>
3
+ Copyright (c) 2026 Borutovk7
4
4
 
5
- Permission to use, copy, modify, and/or distribute this software for any
6
- purpose with or without fee is hereby granted, provided that the above
7
- copyright notice and this permission notice appear in all copies.
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
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
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
- # 🚀 StickEngine
1
+ # @boruto_vk7/stickengine
2
2
 
3
- O **StickEngine** é um motor de alta performance para criação de figurinhas do WhatsApp, projetado para ser simples para iniciantes e extremamente poderoso para desenvolvedores avançados.
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
- ## 📦 1. Começando (Básico)
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
- ### Sua Primeira Figurinha
21
- Gere uma figurinha com apenas 3 linhas de código:
22
- ```javascript
23
- const engine = new StickEngine();
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
- ## 🛠️ 2. Personalizando (Intermediário)
29
+ ## Quick start (easiest)
32
30
 
33
- ### Adicionando Nome e Autor (Metadados)
34
- Personalize as informações que aparecem quando alguém clica na figurinha no WhatsApp.
35
- ```javascript
36
- const engine = new StickEngine({
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: 'Meu Pack Incrível',
39
- author: 'Borutovk7'
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
- ### Figurinhas Animadas (GIF e Vídeo)
45
- O motor detecta automaticamente se o arquivo é animado. Ele corta para 6 segundos e garante que o arquivo tenha menos de 1MB.
46
- ```javascript
47
- engine.addFile('./video_engracado.mp4');
48
- engine.addFile('./dancinha.gif');
49
- await engine.start();
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
- ## 🎨 3. Efeitos Especiais (Avançado)
73
+ ## Baileys example
55
74
 
56
- ### Recorte Circular e Filtros
57
- Transforme imagens quadradas em círculos e aplique filtros profissionais.
58
- ```javascript
59
- const engine = new StickEngine({
60
- edit: {
61
- circle: true, // Recorte circular
62
- sepia: true, // Filtro antigo
63
- brightness: 0.2 // Aumenta o brilho
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
- ### Legendas com Borda (Meme Style)
69
- Adicione texto que pode ser lido em qualquer fundo graças ao contorno (stroke).
70
- ```javascript
71
- const engine = new StickEngine({
72
- edit: {
73
- text: {
74
- content: 'QUEBRADO!',
75
- color: 'WHITE',
76
- stroke: true // Adiciona borda preta ao texto branco
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
- ## 💎 4. Funções Profissionais (Expert)
143
+ ## More features
85
144
 
86
- ### Texto para Figurinha (TP)
87
- Gere figurinhas de frases do zero, sem precisar de uma imagem de base.
88
- ```javascript
89
- const path = await engine.createTextSticker("ESSA É TOP!", {
90
- color: 'WHITE',
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
- ### Criando Ícone do Pacote (Tray Icon)
96
- Gere o ícone de bandeja (96x96) necessário para pacotes oficiais.
97
- ```javascript
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
- ### Auto-Dimensionamento Inteligente
102
- O motor reduz automaticamente a qualidade e o FPS se a figurinha animada passar de 1MB, garantindo que ela sempre seja enviada com sucesso.
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
- ## 📑 5. Referência Técnica Completa
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
- ### Opções do Construtor (`StickEngineOptions`)
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
- ### Opções de Edição (`JimpOptions`)
116
- | Opção | Descrição |
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
- ## 🤝 Créditos
127
- Desenvolvido por **Borutovk7**.
207
+ ## License
128
208
 
129
- ## 📄 Licença
130
- ISC
209
+ MIT · [Borutovk7](https://github.com/Borutovk7)