@boruto_vk7/stickengine 0.0.5 → 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,121 +1,209 @@
1
- # 🚀 StickEngine
1
+ # @boruto_vk7/stickengine
2
2
 
3
- **StickEngine** é um motor poderoso e leve para criação de figurinhas do WhatsApp (estáticas e animadas) com suporte integrado a filtros de imagem, adição de texto e remoção de fundo. Projetado para funcionar em qualquer lugar, do **Termux** a servidores dedicados.
3
+ Simple **WhatsApp sticker** engine for Node.js.
4
4
 
5
- [![NPM Version](https://img.shields.io/npm/v/@boruto_vk7/stickengine?style=flat-square)](https://www.npmjs.com/package/@boruto_vk7/stickengine)
6
- [![License](https://img.shields.io/npm/l/@boruto_vk7/stickengine?style=flat-square)](https://github.com/Borutovk7/StickEngine)
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.
7
12
 
8
13
  ---
9
14
 
10
- ## ✨ Funcionalidades
15
+ ## Install
11
16
 
12
- - 🎞️ **Figurinhas Animadas**: Suporte automático para GIFs e Vídeos (MP4).
13
- - 🎨 **Filtros Profissionais**: Sépia, Tons de Cinza, Inversão e Desfoque (Blur).
14
- - ✍️ **Texto Customizado**: Adicione legendas diretamente na figurinha.
15
- - ✂️ **Remoção de Fundo**: Integração com a API `remove.bg`.
16
- - 🧹 **Limpeza Automática**: Sistema de gerenciamento de arquivos temporários com o método `.clean()`.
17
- - 🏷️ **Metadados (Exif)**: Personalize o nome do pacote e o autor sem complicação.
18
- - 📱 **Termux Friendly**: Sem dependências nativas pesadas como `sharp`.
17
+ ```bash
18
+ npm install @boruto_vk7/stickengine
19
+ ```
20
+
21
+ ```bash
22
+ # system dependency
23
+ sudo apt install ffmpeg # Debian/Ubuntu
24
+ # brew install ffmpeg # macOS
25
+ ```
19
26
 
20
27
  ---
21
28
 
22
- ## 🖼️ Exemplos Visuais
29
+ ## Quick start (easiest)
23
30
 
24
- | Filtro Séia + Texto | Figurinha Animada (Mockup) |
25
- | :---: | :---: |
26
- | ![Sepia Preview](assets/preview_sepia.png) | ![Animated Preview](assets/preview_animated.png) |
31
+ ### ESM / TypeScript
27
32
 
28
- ---
33
+ ```ts
34
+ import StickEngine from '@boruto_vk7/stickengine';
29
35
 
30
- ## 📦 Instalação
36
+ // path | URL | Buffer
37
+ const sticker = await StickEngine.create('./cat.gif', {
38
+ metadata: {
39
+ pack: 'My Pack',
40
+ author: 'Boruto',
41
+ emojis: ['😺'],
42
+ },
43
+ });
31
44
 
32
- ```bash
33
- npm install @boruto_vk7/stickengine
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' },
59
+ });
34
60
  ```
35
61
 
36
- > **Requisito:** Certifique-se de ter o [FFmpeg](https://ffmpeg.org/) instalado no seu sistema. No Termux: `pkg install ffmpeg`.
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
69
+ ```
37
70
 
38
71
  ---
39
72
 
40
- ## 🚀 Como Usar (Exemplos Técnicos)
73
+ ## Baileys example
41
74
 
42
- ### 1. Criando uma Figurinha Estática Simples
43
- ```javascript
75
+ ```ts
44
76
  import StickEngine from '@boruto_vk7/stickengine';
45
77
 
46
- const engine = new StickEngine();
47
- engine.addFile('https://exemplo.com/foto.jpg');
78
+ const sticker = await StickEngine.create(mediaBuffer, {
79
+ metadata: { pack: 'Waguri', author: 'Bot' },
80
+ });
48
81
 
49
- const results = await engine.start();
50
- console.log('Caminho do WebP:', results[0].value);
51
- engine.clean();
82
+ await sock.sendMessage(jid, {
83
+ sticker: sticker.buffer,
84
+ });
52
85
  ```
53
86
 
54
- ### 2. Figurinha Animada (GIF ou Vídeo)
55
- O motor detecta automaticamente a duração e converte para WebP animado.
56
- ```javascript
57
- const engine = new StickEngine({
58
- fps: 20, // Aumenta a fluidez
59
- quality: 70 // Otimiza o tamanho para o WhatsApp
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',
60
111
  });
112
+ ```
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 |
61
124
 
62
- engine.addFile('./video_engracado.mp4');
63
- await engine.start();
64
- engine.clean();
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
+ }
65
139
  ```
66
140
 
67
- ### 3. Aplicando Filtros e Texto
68
- ```javascript
141
+ ---
142
+
143
+ ## More features
144
+
145
+ ### Text sticker
146
+
147
+ ```ts
69
148
  const engine = new StickEngine({
70
- edit: {
71
- sepia: true,
72
- blur: 5,
73
- text: {
74
- content: 'MUITO BOM!',
75
- alignmentY: 2 // 0: Topo, 1: Meio, 2: Baixo
76
- }
77
- }
149
+ metadata: { pack: 'TP', author: 'Me' },
78
150
  });
151
+ const sticker = await engine.createTextSticker('TOP!', { color: 'WHITE' });
152
+ ```
153
+
154
+ ### Tray icon (96×96)
79
155
 
80
- engine.addFile(bufferDeImagem);
81
- await engine.start();
82
- engine.clean();
156
+ ```ts
157
+ const engine = new StickEngine();
158
+ const trayPath = await engine.createTrayIcon('./logo.png');
83
159
  ```
84
160
 
85
- ### 4. Remoção de Fundo (Remove.bg)
86
- ```javascript
87
- const engine = new StickEngine({
88
- transparent: 'SUA_API_KEY_AQUI'
89
- });
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
90
171
 
91
- engine.addFile('foto_com_fundo.png');
92
- await engine.start();
93
- engine.clean();
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));
94
178
  ```
95
179
 
96
180
  ---
97
181
 
98
- ## ⚙️ Opções do Construtor
182
+ ## Animated WebP EXIF fix
99
183
 
100
- | Opção | Tipo | Padrão | Descrição |
101
- | :--- | :--- | :--- | :--- |
102
- | `metadata` | `Object` | `{ pack: 'StickEngine', author: 'Borutovk7' }` | Nome do pacote e autor. |
103
- | `edit` | `Object` | `false` | Filtros (`sepia`, `greyscale`, `invert`, `blur`) e `text`. |
104
- | `transparent` | `String` | `false` | Chave da API `remove.bg` para remover fundo. |
105
- | `autoClean` | `Boolean` | `true` | Habilita o rastreio de arquivos para limpeza. |
106
- | `quality` | `Number` | `80` | Qualidade do WebP (1-100). |
107
- | `fps` | `Number` | `15` | Frames por segundo para animações. |
184
+ Older builds called `img.save()` on **animated** stickers, which throws:
108
185
 
109
- ---
186
+ ```text
187
+ Using `save` for animations is not currently supported. Use `muxAnim` instead
188
+ ```
189
+
190
+ This version:
110
191
 
111
- ## 🤝 Contribuições
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
+ ---
112
199
 
113
- Contribuições são sempre bem-vindas! Sinta-se à vontade para abrir uma **Issue** ou enviar um **Pull Request**.
200
+ ## Requirements
114
201
 
115
- Desenvolvido por [Borutovk7](https://github.com/Borutovk7) e [Eduh Dev](https://github.com/EduhDev).
202
+ - Node.js **≥ 18**
203
+ - `ffmpeg` + `ffprobe` in `PATH`
116
204
 
117
205
  ---
118
206
 
119
- ## 📄 Licença
207
+ ## License
120
208
 
121
- Este projeto está sob a licença [ISC](LICENSE).
209
+ MIT · [Borutovk7](https://github.com/Borutovk7)