@boruto_vk7/stickengine 2.0.4 → 4.1.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.
Files changed (61) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +226 -119
  3. package/assets/DejaVuSans.ttf +0 -0
  4. package/assets/LICENSE-DejaVuSans.txt +78 -0
  5. package/dist/cjs/StickEngine.d.ts +287 -0
  6. package/dist/cjs/StickEngine.js +1191 -573
  7. package/dist/cjs/StickEngine.js.map +1 -1
  8. package/dist/cjs/canvas.d.ts +16 -0
  9. package/dist/cjs/canvas.js +108 -0
  10. package/dist/cjs/canvas.js.map +1 -0
  11. package/dist/cjs/compat.d.ts +8 -0
  12. package/dist/cjs/compat.js +18 -5
  13. package/dist/cjs/compat.js.map +1 -1
  14. package/dist/cjs/index.d.ts +12 -0
  15. package/dist/cjs/index.js +18 -20
  16. package/dist/cjs/index.js.map +1 -1
  17. package/dist/cjs/logger.d.ts +12 -0
  18. package/dist/cjs/logger.js +68 -0
  19. package/dist/cjs/logger.js.map +1 -0
  20. package/dist/cjs/logo.png +0 -0
  21. package/dist/cjs/package.json +1 -1
  22. package/dist/cjs/util.d.ts +71 -0
  23. package/dist/cjs/util.js +437 -0
  24. package/dist/cjs/util.js.map +1 -0
  25. package/dist/esm/StickEngine.d.ts +287 -0
  26. package/dist/esm/StickEngine.js +1182 -500
  27. package/dist/esm/StickEngine.js.map +1 -1
  28. package/dist/esm/canvas.d.ts +16 -0
  29. package/dist/esm/canvas.js +96 -0
  30. package/dist/esm/canvas.js.map +1 -0
  31. package/dist/esm/compat.d.ts +8 -0
  32. package/dist/esm/compat.js +8 -1
  33. package/dist/esm/compat.js.map +1 -1
  34. package/dist/esm/index.d.ts +12 -0
  35. package/dist/esm/index.js +10 -1
  36. package/dist/esm/index.js.map +1 -1
  37. package/dist/esm/logger.d.ts +12 -0
  38. package/dist/esm/logger.js +59 -0
  39. package/dist/esm/logger.js.map +1 -0
  40. package/dist/esm/logo.png +0 -0
  41. package/dist/esm/package.json +3 -0
  42. package/dist/esm/util.d.ts +71 -0
  43. package/dist/esm/util.js +379 -0
  44. package/dist/esm/util.js.map +1 -0
  45. package/dist/types/StickEngine.d.ts +195 -18
  46. package/dist/types/StickEngine.d.ts.map +1 -1
  47. package/dist/types/canvas.d.ts +17 -0
  48. package/dist/types/canvas.d.ts.map +1 -0
  49. package/dist/types/compat.d.ts +8 -1
  50. package/dist/types/compat.d.ts.map +1 -1
  51. package/dist/types/index.d.ts +11 -2
  52. package/dist/types/index.d.ts.map +1 -1
  53. package/dist/types/logger.d.ts +13 -0
  54. package/dist/types/logger.d.ts.map +1 -0
  55. package/dist/types/util.d.ts +72 -0
  56. package/dist/types/util.d.ts.map +1 -0
  57. package/logo.png +0 -0
  58. package/logo_small.png +0 -0
  59. package/package.json +34 -12
  60. package/dist/cjs/emror.jpg +0 -0
  61. package/dist/esm/emror.jpg +0 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Borutovk7 - Lagos Solutions
4
+
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:
11
+
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,173 +1,280 @@
1
- # StickEngine - Lagos Solutions
1
+ # @boruto_vk7/stickengine
2
2
 
3
- ![Lagos Solutions](./logo_small.png)
3
+ [![npm](https://img.shields.io/npm/v/@boruto_vk7/stickengine)](https://www.npmjs.com/package/@boruto_vk7/stickengine)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
5
+ [![Node](https://img.shields.io/node/v/@boruto_vk7/stickengine)](package.json)
4
6
 
5
- **Motor profissional de figurinhas para WhatsApp**
6
- Estático e animado, com EXIF, marca d'água com sua logo e suporte total ESM + CJS + TypeScript
7
+ A WhatsApp sticker engine that prepares production-ready sticker media. It converts images, videos, GIFs, and WebP files into WhatsApp-compliant WebP stickers (512x512, animated or static), removes letterbox borders, writes sticker-pack EXIF metadata, and produces the WebP + OGG/Opus media pair required for WhatsApp audio stickers.
7
8
 
8
- [![npm](https://img.shields.io/npm/v/@boruto_vk7/stickengine?style=flat-square&color=7c3aed)](https://www.npmjs.com/package/@boruto_vk7/stickengine)
9
- [![node](https://img.shields.io/node/v/@boruto_vk7/stickengine?style=flat-square&color=7c3aed)](https://nodejs.org)
10
- [![license](https://img.shields.io/badge/License-MIT-7c3aed?style=flat-square)](LICENSE)
11
- [![Lagos](https://img.shields.io/badge/Lagos-Solutions-7c3aed?style=flat-square)](https://www.npmjs.com/package/@boruto_vk7/stickengine)
9
+ The library prepares media only. It does not connect to WhatsApp, does not send messages, and has no dependency on any WhatsApp client library. Your application owns the connection and the sending logic; this package guarantees that what you send is valid sticker media.
12
10
 
13
- ![Lagos Solutions Logo](./logo.png)
11
+ ## Feature summary
14
12
 
15
- > SOLUÇÕES INTELIGENTES. RESULTADOS REAIS.
13
+ - **Full-bleed output by default.** Media is scaled to cover the entire 512x512 canvas; the surplus is cropped from the center. No black bars and no transparent padding in the output (`fit: 'cover'`). The legacy letterboxed layout remains available with `fit: 'natural'`.
14
+ - **Automatic border removal.** Letterbox bars baked into the source file are detected (pixel scan for images, `cropdetect` plus sampled frames for video) and cropped before scaling.
15
+ - **Audio stickers.** `createAudioSticker()` returns the complete media pair required by the WhatsApp protocol — an animated or static WebP sticker plus an OGG/Opus audio clip — with duration metadata.
16
+ - **Bundled native binaries.** ffmpeg, ffprobe, and the `@napi-rs/canvas` native binary are installed as npm dependencies of their own platform packages. Nothing needs to be installed on the host system.
17
+ - **Size compliance with automatic negotiation.** Static stickers are driven to the 100 KB WhatsApp limit and animated stickers to 1 MB, by reducing quality and frame rate across successive encode attempts.
18
+ - **Sticker pack metadata.** Pack name, author, and emoji categories are written as EXIF via `node-webpmux`, with a raw RIFF-container fallback injection.
19
+ - **Watermarks and filters.** Image or text watermarks on both static and animated output; greyscale, sepia, invert, blur, brightness, contrast, circular crop, and caption text through the canvas (Skia) pipeline.
20
+ - **Dual packaging.** ESM and CJS builds generated from a single TypeScript source, with type definitions and source maps.
21
+ - **Structured logging and diagnostics.** Chalk-formatted console output with fixed tags and real measurements, a global kill switch, per-instance silence, and programmatic events that mirror every log line.
16
22
 
17
- ---
23
+ ## Relation to existing alternatives
18
24
 
19
- ## 🚀 Instalação
25
+ The most widely installed package in this space, `wa-sticker-formatter` (4.4.4), and its direct derivatives have been dormant since 2023 and share a common design: a single `Sticker` class, Jimp/sharp for images, a system ffmpeg dependency, and no size targeting. StickEngine was built as a maintained alternative with a different scope:
20
26
 
21
- ```bash
22
- npm install @boruto_vk7/stickengine
23
- ```
27
+ | Capability | StickEngine v4.1 | wa-sticker-formatter and derivatives |
28
+ | --- | --- | --- |
29
+ | Output 512x512, WhatsApp-compliant | Yes | Yes |
30
+ | Letterbox border removal | Automatic (pixel scan + `cropdetect`) | Not provided |
31
+ | Full-bleed ("giant sticker") fit | Default (`fit: 'cover'`) | Not provided |
32
+ | Audio sticker media pair (WebP + OGG/Opus) | Yes, native API | Not provided |
33
+ | Target file size with auto quality/fps negotiation | 100 KB static / 1 MB animated | Not provided |
34
+ | Bundled ffmpeg (no system install) | Yes | Requires system ffmpeg |
35
+ | Sticker pack EXIF | Yes, with RIFF fallback | Yes |
36
+ | Message sending | Deliberately excluded | Not provided |
37
+ | ESM + CJS + TypeScript types | Yes | CJS |
24
38
 
25
- FFmpeg já incluso via `@ffmpeg-installer/ffmpeg`. Não precisa instalar manualmente.
39
+ Adoption favors the older packages; on the capabilities listed above, StickEngine is the more complete option. The comparison reflects the feature sets documented in each project's public README as of the time of writing.
26
40
 
27
- ---
41
+ ## Installation
28
42
 
29
- ## ✨ Funcionalidades
43
+ ```bash
44
+ npm install @boruto_vk7/stickengine
45
+ ```
30
46
 
31
- - ✅ **Todos os tipos de entrada:** Buffer, caminho local, URL https, data URI base64, base64 puro
32
- - ✅ **Todos os tipos de figurinha:** JPG, PNG, WEBP estático, GIF animado, MP4, WEBM
33
- - ✅ **5 modos de enquadramento:** `natural` (padrão WA), `cover`, `contain`, `fill`, `none`
34
- - ✅ **EXIF com pack e autor:** Compatível com node-webpmux v1 e v3
35
- - ✅ **Auto shrink:** Figurinhas animadas sempre abaixo de 1MB
36
- - ✅ **Dirtemp custom:** `Dirtemp`, `tempDir`, `dirTemp` - qualquer alias funciona
37
- - ✅ **Marca d'água com LOGO:** `watermark: true` usa sua `logo.png` automaticamente
38
- - ✅ **Compatível:** ESM `import`, CJS `require()`, TypeScript `NodeNext` e `CommonJS`
39
- - ✅ **APIs antigas:** `sendImageAsSticker`, `imageToWebp`, `writeExifImg` ainda funcionam
47
+ Requirements: Node.js >= 18. On first install, npm downloads the platform packages for ffmpeg, ffprobe, and the native canvas binary; no compiler toolchain and no system-wide installation are required. To use a system ffmpeg instead (for example, one newer than the bundled 4.1 build, needed only when re-encoding incoming animated WebP stickers), pass `ffmpegPath`/`ffprobePath` or call `setFfmpegBinaryPaths()`.
40
48
 
41
- ---
49
+ ## Usage
42
50
 
43
- ## 📦 Uso Rápido
51
+ ### Static sticker from an image
44
52
 
45
- ### ESM / TypeScript
46
- ```javascript
53
+ ```js
47
54
  import StickEngine from '@boruto_vk7/stickengine';
48
55
 
49
- const sticker = await StickEngine.create('./foto.jpg', {
50
- Dirtemp: './temp',
51
- watermark: true,
52
- metadata: {
53
- pack: 'Lagos Solutions',
56
+ const result = await StickEngine.create(imageBuffer, {
57
+ packname: 'My Pack',
54
58
  author: 'Borutovk7',
55
- emojis: ['🔥']
56
- }
57
59
  });
58
-
59
- await sock.sendMessage(jid, { sticker: sticker.buffer });
60
+ // result.buffer -> WebP 512x512, <= 100 KB, EXIF written
61
+ // result.animated -> false
62
+ // result.cropped -> border rectangle removed, or null
63
+ // result.base64 -> same buffer as base64
60
64
  ```
61
65
 
62
- ### CommonJS
63
- ```javascript
64
- const StickEngine = require('@boruto_vk7/stickengine');
66
+ ### Animated sticker from a video or GIF
65
67
 
66
- const buffer = await StickEngine.toBuffer('./video.mp4', {
67
- Dirtemp: '/tmp/meus-stickers',
68
- watermark: false,
69
- fit: 'natural',
70
- metadata: { pack: 'Meu Pack', author: 'Bot' }
68
+ ```js
69
+ const result = await StickEngine.create(videoBuffer, {
70
+ fps: 15,
71
+ maxDuration: 3, // seconds (free parameter)
72
+ startTime: 0,
71
73
  });
74
+ // result.buffer -> animated WebP 512x512, <= 1 MB
72
75
  ```
73
76
 
74
- ### Com marca d'água LOGO
77
+ ### Audio sticker
75
78
 
76
- ```javascript
77
- await StickEngine.create('./imagem.png', {
78
- Dirtemp: './temp',
79
- watermark: true,
80
- metadata: { pack: 'Lagos', author: 'Solutions' }
81
- });
79
+ WhatsApp implements audio stickers as a `StickerMessage` carrying an embedded `AudioMessage` (`WAProto`: `oneof audio { AudioMessage audioMessage = 26; }`). Two files are required. `createAudioSticker()` prepares both:
80
+
81
+ ```js
82
+ import { createAudioSticker, toStickerAudio } from '@boruto_vk7/stickengine';
82
83
 
83
- await StickEngine.create('./imagem.png', {
84
- watermark: { image: './logo.png', position: 'center', size: 0.4, opacity: 0.6 },
85
- metadata: { pack: 'Pack', author: 'Author' }
84
+ // Case 1: video with a sound track - the audio is taken from the video itself
85
+ const pack = await createAudioSticker(videoBuffer, {
86
+ audioSeconds: 10, // clip length, free parameter
87
+ metadata: { pack: 'My Pack', author: 'Borutovk7' },
86
88
  });
87
89
 
88
- await StickEngine.create('./imagem.png', {
89
- watermark: false,
90
- metadata: { pack: 'Sem marca', author: 'Bot' }
90
+ // Case 2: still image + separate audio (for example, a music download)
91
+ const music = await toStickerAudio(mp3Buffer, { seconds: 15 });
92
+ const pack2 = await createAudioSticker(imageBuffer, {
93
+ audio: music.buffer,
91
94
  });
95
+ // pack.sticker -> WebP 512x512 with EXIF (static or animated)
96
+ // pack.audio -> OGG/Opus ('audio/ogg; codecs=opus')
97
+ // pack.seconds -> audio duration in seconds
98
+ // pack.animated -> whether the sticker is animated
92
99
  ```
93
100
 
94
- ---
95
-
96
- ## 🎨 Modos de Enquadramento
97
-
98
- ```javascript
99
- await StickEngine.create(input, { fit: 'natural' });
101
+ The media pair maps directly onto the protocol fields used when sending (see below).
102
+
103
+ ### Sending from your application (not part of this library)
104
+
105
+ ```js
106
+ // Bot-side code. Uses Baileys in this example; any client library works,
107
+ // because the engine only produced the buffers.
108
+ import { prepareWAMessageMedia, generateWAMessageFromContent } from '@whiskeysockets/baileys';
109
+
110
+ const stickerMedia = await prepareWAMessageMedia(
111
+ { sticker: pack.sticker },
112
+ { upload: sock.waUploadToServer },
113
+ );
114
+ const audioMedia = await prepareWAMessageMedia(
115
+ { audio: pack.audio },
116
+ { upload: sock.waUploadToServer },
117
+ );
118
+
119
+ const content = {
120
+ stickerMessage: {
121
+ ...stickerMedia.stickerMessage,
122
+ audioMessage: {
123
+ ...audioMedia.audioMessage,
124
+ seconds: Math.round(pack.seconds) || undefined,
125
+ ptt: false,
126
+ },
127
+ },
128
+ };
129
+
130
+ const msg = generateWAMessageFromContent(jid, content, { userJid: sock.user.id });
131
+ await sock.relayMessage(jid, msg.message, { messageId: msg.key.id });
100
132
  ```
101
133
 
102
- | Fit | Resultado |
103
- |-----|-----------|
104
- | `natural` (padrão) | Mantém proporção, lado maior = 512px - visual real do WhatsApp |
105
- | `cover` | Força 512x512 quadrado com corte central |
106
- | `contain` | Encaixa dentro de 512x512 com fundo transparente |
107
- | `fill` | Estica para 512x512 |
108
- | `none` | Só diminui se maior que 512, nunca aumenta |
109
-
110
- ---
134
+ ### Queue processing
111
135
 
112
- ## 📁 Dirtemp Personalizado
113
-
114
- Aceita qualquer alias:
136
+ ```js
137
+ const engine = new StickEngine({ concurrency: 3, packname: 'My Pack' });
138
+ engine.add(file1, file2, file3);
139
+ const settled = await engine.start(); // PromiseSettledResult<string> per input
140
+ engine.clean(); // removes generated files
141
+ ```
115
142
 
116
- ```javascript
117
- new StickEngine({ Dirtemp: './minha-pasta' })
118
- new StickEngine({ tempDir: './minha-pasta' })
119
- new StickEngine({ dirTemp: './minha-pasta' })
143
+ ## Accepted inputs
144
+
145
+ `Buffer`, file path, `http(s)` URL, raw base64, and `data:` URIs. Input type is detected from content, not extension. Inputs above 200 MB are rejected.
146
+
147
+ ## API
148
+
149
+ ### Static factories
150
+
151
+ | Method | Returns |
152
+ | --- | --- |
153
+ | `StickEngine.create(input, options?)` | `StickResult` |
154
+ | `StickEngine.toBuffer(input, options?)` | `Buffer` (WebP) |
155
+ | `StickEngine.toBase64String(input, options?)` | `string` |
156
+ | `StickEngine.toFile(input, options?)` | `string` (file path) |
157
+ | `StickEngine.toStickerAudio(input, options?)` | `StickerAudioResult` |
158
+ | `StickEngine.createAudioSticker(visual, options?)` | `AudioStickerResult` |
159
+
160
+ ### Free functions
161
+
162
+ | Function | Description |
163
+ | --- | --- |
164
+ | `toStickerAudio(input, options?)` | Any audio or video to OGG/Opus. Returns `{ buffer, seconds, mime, bitrate }`. |
165
+ | `createAudioSticker(visual, options?)` | Prepares the audio sticker pair. See `AudioStickerResult`. |
166
+ | `getBuffer(url, options?)` | HTTP download with explicit error reporting (status code and network code). |
167
+ | `setFfmpegBinaryPaths({ ffmpegPath?, ffprobePath? })` | Overrides the bundled binaries globally. |
168
+ | `setLogsEnabled(bool)` / `logsEnabled()` | Global log switch. |
169
+ | `getImageBackend()` | `'canvas'` or `'jimp'` - the image backend in use. |
170
+ | `imageToWebp` / `videoToWebp` / `writeExifImg` / `writeExifVid` (+ `*2` aliases) | Legacy v2 helpers, retained for compatibility. |
171
+ | `normalizeMetadata(options)` | Resolves pack/author/emoji metadata from any accepted alias. |
172
+
173
+ The `@boruto_vk7/stickengine/compat` subpath exports the conversion helpers only (`imageToWebp`, `videoToWebp`, `writeExifImg`, `writeExifVid`, `normalizeMetadata`, `getBuffer`). The send functions that existed in v2 were removed, not deprecated.
174
+
175
+ ### Result types
176
+
177
+ ```ts
178
+ interface StickResult {
179
+ path: string; // generated file (temporary unless kept)
180
+ buffer: Buffer; // WebP media
181
+ base64: string;
182
+ animated: boolean;
183
+ width: number; // 512
184
+ height: number; // 512
185
+ size: number; // bytes
186
+ duration: number; // animated: seconds; static: 0
187
+ cropped: CropRect | null;
188
+ warnings: string[]; // non-fatal conditions, e.g. size target missed
189
+ }
190
+
191
+ interface StickerAudioResult {
192
+ buffer: Buffer; // OGG/Opus
193
+ seconds: number;
194
+ mime: string; // 'audio/ogg; codecs=opus'
195
+ bitrate: number;
196
+ }
197
+
198
+ interface AudioStickerResult {
199
+ sticker: Buffer;
200
+ audio: Buffer;
201
+ seconds: number;
202
+ animated: boolean;
203
+ audioMime: string;
204
+ stickerSize: number;
205
+ audioSize: number;
206
+ warnings: string[];
207
+ }
120
208
  ```
121
209
 
122
- Padrão: `os.tmpdir()/stickengine`
210
+ ### Options
123
211
 
124
- ---
212
+ Engine options (all optional):
125
213
 
126
- ## 💧 Marca d'água LOGO
214
+ | Option | Default | Description |
215
+ | --- | --- | --- |
216
+ | `fit` | `'cover'` | Canvas fit. `'cover'` scales the media to fill 512x512 and center-crops the surplus (no borders). `'natural'`/`'contain'` letterboxes with transparent padding. `'fill'` stretches; `'none'` never upscales. |
217
+ | `cropBorders` / `cortarBordas` / `removerBordas` | `true` | Border removal. Accepts an object: `{ tolerance, color: 'black'\|'white'\|'auto', margin, minSize, transparent }`. `minSize` (area fraction, default `0.05`) prevents destructive crops on dark artwork. |
218
+ | `cropTolerance`, `cropColor`, `cropMargin`, `cropMinSize`, `cropTransparent` | `26`, `'black'`, `2`, `0.05`, `true` | Shorthand for the object form above. |
219
+ | `metadata` (or `packname`, `author`, `categories`) | `'Lagos Solutions'`, `'StickEngine'`, `['✨']` | Sticker pack EXIF. |
220
+ | `watermark` / `marcaDagua` (and PT aliases) | `false` | `true` (bundled logo), a file path, or `{ image?, text?, position, opacity, margin, sizePercent }`. |
221
+ | `edit` | `false` | `false`, `true`, or an object: `greyscale`, `invert`, `sepia`, `blur`, `brightness`, `contrast`, `circle`, `resize`, `text`. |
222
+ | `fps` | `15` | Frame rate of animated output. |
223
+ | `maxDuration` / `tempoMaximo` | `3` | Maximum animated duration in seconds. |
224
+ | `startTime` / `tempoInicio` | `0` | Skip the first N seconds of the video. |
225
+ | `maxSize` | `1000000` | Animated size target (bytes). |
226
+ | `maxSizeStatic` | `100000` | Static size target (bytes). |
227
+ | `quality` | `90` static, `80` animated | Initial encode quality (1-100). Auto-shrink may lower it. |
228
+ | `lossless` | `false` | Lossless WebP (static). Size targets still apply. |
229
+ | `passthroughWebp` | `false` | Copy an input WebP without re-encoding (opt-in). |
230
+ | `tempDir` (plus legacy aliases) | `os.tmpdir()/stickengine` | Working directory for intermediates. |
231
+ | `concurrency` | `3` | Queue worker count (1-16). |
232
+ | `ffmpegPath`, `ffprobePath` | bundled | Alternative binaries. |
233
+ | `silent` | `false` | Disables all console logging for this instance. |
234
+ | `logs` | `true` | Inverse alias: `logs: false` equals `silent: true`. |
127
235
 
128
- Sua logo `logo.png` é usada automaticamente:
236
+ Audio options (used by `toStickerAudio` and `createAudioSticker`):
129
237
 
130
- ```javascript
131
- { watermark: true }
132
- { watermark: false }
133
- { watermark: './caminho/para/outra-logo.png' }
134
- { watermark: { image: './logo.png', position: 'bottom-right', size: 0.25 } }
135
- { marcaDagua: true }
136
- ```
238
+ | Option | Default | Description |
239
+ | --- | --- | --- |
240
+ | `audio` | `null` | External audio to pair. When omitted and the visual is a video, its own track is used. |
241
+ | `audioStartTime` / `startTime` | `0` | Clip start position, seconds. |
242
+ | `audioSeconds` / `seconds` | full audio | Clip length in seconds. Free parameter. |
243
+ | `audioBitrate` / `bitrate` | `64` | Opus bitrate, 16-320 kbps. |
244
+ | `audioMono` / `mono` | `false` | Force mono. |
245
+ | `audioSampleRate` / `sampleRate` | `48000` | Sample rate, 8000-96000 Hz. |
137
246
 
138
- Posições: `bottom-right`, `bottom-left`, `top-right`, `top-left`, `center`
247
+ ## Events
139
248
 
140
- ---
249
+ The `StickEngine` class extends `EventEmitter`. Each event carries an object describing a real step of the pipeline:
141
250
 
142
- ## 🔄 Compatibilidade com código antigo
251
+ `st.start`, `st.info`, `st.data`, `st.warn`, `st.error`, `st.done`, `st.audio`, `st.audioSticker`
143
252
 
144
- ```javascript
145
- const { sendImageAsSticker } = require('@boruto_vk7/stickengine');
146
- await sendImageAsSticker(conn, jid, './foto.jpg', quoted, {
147
- packname: 'Meu Pack',
148
- author: 'Bot',
149
- categories: ['🔥']
150
- });
151
- ```
253
+ Events are independent of console logging and continue to fire when logging is disabled.
254
+
255
+ ## Logging and error handling
152
256
 
153
- ---
257
+ Console output is produced only for operations that actually occurred, with fixed tags (`STICKER`, `CROP`, `CANVAS`, `ENCODE`, `EXIF`, `AUDIO`, `AUDIO-STICKER`, `AVISO`, `ERRO`), timestamps, and real measurements. It can be silenced per instance (`silent: true`, `logs: false`) or globally (`setLogsEnabled(false)`).
154
258
 
155
- ## 📊 Testado
259
+ Failures throw. Error messages state the failed operation and its cause: download errors include the HTTP status and network code, ffmpeg failures include the encoder message, and media without an audio track produces a message that names the input type. Warnings are collected in `result.warnings` instead of being printed as fake successes.
156
260
 
157
- - ✅ PNG, JPG, WEBP transparente, GIF, MP4, WEBM
158
- - ✅ Buffer, Path local, URL https, Data URI base64, Base64 puro
159
- - ✅ Dirtemp custom
160
- - ✅ Watermark logo e texto
161
- - ✅ Fit natural, cover, contain, fill, none
162
- - ✅ ESM + CJS dual package
163
- - ✅ Foto real com logo Lagos Solutions no canto e no centro
261
+ ## Behavior notes and limits
164
262
 
165
- ---
263
+ - Static output: 512x512 WebP, driven to <= 100 KB. Animated output: 512x512 WebP, driven to <= 1 MB. When the target cannot be met, the result is returned with a warning rather than discarded.
264
+ - With `fit: 'cover'`, the output canvas is always fully covered by media; border artifacts cannot appear in the output. Borders baked into the source are removed beforehand by the border-detection pass.
265
+ - The bundled ffmpeg 4.1 build cannot decode animated WebP input. Such input is preserved without re-encoding and a warning is emitted. Provide a system ffmpeg >= 4.3 through `ffmpegPath` to normalize those files.
266
+ - Audio is always OGG/Opus at the configured sample rate (`audio/ogg; codecs=opus`), the format consumed natively by WhatsApp.
267
+ - EXIF writing uses `node-webpmux`; if the muxer rejects a file, an EXIF chunk is injected directly into the RIFF container, creating a `VP8X` chunk when required.
166
268
 
167
- ## 📄 Licença
269
+ ## Migration from v2/v3
168
270
 
169
- MIT - Lagos Solutions
271
+ | Before | v4 |
272
+ | --- | --- |
273
+ | `sendImageAsSticker(conn, jid, input, ...)` | Removed. Use `StickEngine.toBuffer(input, opts)` and send the buffer with your client library. |
274
+ | `sendVideoAsSticker(...)`, `send*2` | Removed. Same pattern as above. |
275
+ | `fit` default `'natural'` (letterboxed) | `'cover'` (full-bleed). Pass `fit: 'natural'` to restore the previous framing. |
276
+ | Text watermark ignored on animated input | Applied as an overlay rendered through the canvas. |
170
277
 
171
- ![Lagos Solutions](./logo_small.png)
278
+ ## License
172
279
 
173
- **SOLUÇÕES INTELIGENTES. RESULTADOS REAIS.**
280
+ MIT. The bundled DejaVu Sans font ships under its free license, documented in `assets/LICENSE-DejaVuSans.txt`.
Binary file
@@ -0,0 +1,78 @@
1
+ Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2
+ Upstream-Name: DejaVu fonts
3
+ Upstream-Author: Stepan Roh <src@users.sourceforge.net> (original author),
4
+ see /usr/share/doc/fonts-dejavu-core/AUTHORS for full list
5
+ Source: https://dejavu-fonts.github.io/
6
+
7
+ Files: *
8
+ Copyright: Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved.
9
+ Bitstream Vera is a trademark of Bitstream, Inc.
10
+ DejaVu changes are in public domain.
11
+ License: bitstream-vera
12
+ Permission is hereby granted, free of charge, to any person obtaining a copy
13
+ of the fonts accompanying this license ("Fonts") and associated
14
+ documentation files (the "Font Software"), to reproduce and distribute the
15
+ Font Software, including without limitation the rights to use, copy, merge,
16
+ publish, distribute, and/or sell copies of the Font Software, and to permit
17
+ persons to whom the Font Software is furnished to do so, subject to the
18
+ following conditions:
19
+ .
20
+ The above copyright and trademark notices and this permission notice shall
21
+ be included in all copies of one or more of the Font Software typefaces.
22
+ .
23
+ The Font Software may be modified, altered, or added to, and in particular
24
+ the designs of glyphs or characters in the Fonts may be modified and
25
+ additional glyphs or characters may be added to the Fonts, only if the fonts
26
+ are renamed to names not containing either the words "Bitstream" or the word
27
+ "Vera".
28
+ .
29
+ This License becomes null and void to the extent applicable to Fonts or Font
30
+ Software that has been modified and is distributed under the "Bitstream
31
+ Vera" names.
32
+ .
33
+ The Font Software may be sold as part of a larger software package but no
34
+ copy of one or more of the Font Software typefaces may be sold by itself.
35
+ .
36
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
37
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY,
38
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT,
39
+ TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME
40
+ FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING
41
+ ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES,
42
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
43
+ THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE
44
+ FONT SOFTWARE.
45
+ .
46
+ Except as contained in this notice, the names of Gnome, the Gnome
47
+ Foundation, and Bitstream Inc., shall not be used in advertising or
48
+ otherwise to promote the sale, use or other dealings in this Font Software
49
+ without prior written authorization from the Gnome Foundation or Bitstream
50
+ Inc., respectively. For further information, contact: fonts at gnome dot
51
+ org.
52
+
53
+ Files: debian/*
54
+ Copyright: (C) 2005-2006 Peter Cernak <pce@users.sourceforge.net>
55
+ (C) 2006-2011 Davide Viti <zinosat@tiscali.it>
56
+ (C) 2011-2013 Christian Perrier <bubulle@debian.org>
57
+ (C) 2013 Fabian Greffrath <fabian+debian@greffrath.com>
58
+ License: GPL-2+
59
+ This program is free software; you can redistribute it
60
+ and/or modify it under the terms of the GNU General Public
61
+ License as published by the Free Software Foundation; either
62
+ version 2 of the License, or (at your option) any later
63
+ version.
64
+ .
65
+ This program is distributed in the hope that it will be
66
+ useful, but WITHOUT ANY WARRANTY; without even the implied
67
+ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
68
+ PURPOSE. See the GNU General Public License for more
69
+ details.
70
+ .
71
+ You should have received a copy of the GNU General Public
72
+ License along with this package; if not, write to the Free
73
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor,
74
+ Boston, MA 02110-1301 USA
75
+ .
76
+ On Debian systems, the full text of the GNU General Public
77
+ License version 2 can be found in the file
78
+ /usr/share/common-licenses/GPL-2'.