Registry / messaging / wa-sticker-formatter

wa-sticker-formatter

JSON →
library4.4.4jsnpmunverified

Wa-Sticker-Formatter v4.4.4 is a Node.js library for creating WhatsApp stickers from images, GIFs, videos, SVG strings, or buffers. It produces WebP files and integrates with Baileys via `toMessage()`. Active development, TypeScript-first with full type definitions. Supports pack/author metadata, emoji categories, background color, cropping/background-fill types, and quality control. CommonJS and ESM compatible, but ESM is recommended for modern projects.

npm install wa-sticker-formatter
INSTALL
IMPORT
SIG · WA-STICKER-FORMATT
W
wa-sticker-formatter
messagingjavascriptv4.4.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Sticker
✓ import { Sticker } from 'wa-sticker-formatter'
✗ import Sticker from 'wa-sticker-formatter'
Named export, not default. Use curly braces.
StickerTypes
✓ import { StickerTypes } from 'wa-sticker-formatter'
✗ const StickerTypes = require('wa-sticker-formatter').StickerTypes
Valid as CommonJS, but ESM is preferred. In TypeScript, destructure the enum.
createSticker
✓ import { createSticker } from 'wa-sticker-formatter'
✗ import { createSticker as create } from 'wa-sticker-formatter'
Renaming is fine functionally but avoid confusion. The function returns a Promise<Buffer>.

Creates a WhatsApp sticker from a local image file with custom pack name, author, type, categories, quality, and background color.

import { Sticker, StickerTypes } from 'wa-sticker-formatter'; import fs from 'fs'; const sticker = new Sticker('path/to/image.jpg', { pack: 'My Pack', author: 'Me', type: StickerTypes.FULL, categories: ['🤩', '🎉'], quality: 80, background: '#FF0000' }); const buffer = await sticker.toBuffer(); fs.writeFileSync('sticker.webp', buffer); // Or directly as a file: await sticker.toFile('sticker.webp');
Debug
Known issues
gotchaInput must be a valid image, GIF, video, or SVG string. Passing a non-image buffer or file path results in an error.
fix
Ensure the input is one of: Buffer (image/gif/video), SVG string, URL, or file path to such a file.
affects: >=4.0
deprecatedThe `Sticker` class constructor with a single buffer argument (without options) is deprecated. Options should be provided as the second argument or via setters.
fix
Use `new Sticker(buffer, options)` or chain `new Sticker(buffer).setPack('...')` etc.
affects: >=4.0
gotchaSticker types `crop` or `full` are case-sensitive. Using wrong casing will fallback to default (crop).
fix
Use `StickerTypes.CROP` or `StickerTypes.FULL` (enum), or the exact strings 'crop' / 'full'.
affects: >=4.0
breakingSharp is required for video-to-webp conversion. If not installed, it throws an error. Versions before 4.x allowed a fallback.
fix
Install sharp: `npm install sharp`
affects: >=4.0
gotchaThe `background` option only works with `type: StickerTypes.FULL`. Using it with `type: crop` or default has no effect.
fix
Set `type: StickerTypes.FULL` if you need a background color.
affects: >=4.0
gotcha`toMessage()` returns an object for Baileys-MD, but it requires a `conn` object with a `sendMessage` method. Using without Baileys will cause errors.
fix
Use `toBuffer()` or `toFile()` if not using Baileys.
affects: >=4.0
gotchaWhen using CommonJS `require`, TypeScript type definitions are not automatically imported. User must import types separately if needed.
fix
Use `import { Sticker } from 'wa-sticker-formatter'` for types, or use `// @ts-ignore` for require.
affects: >=4.0
Errors
Common errors & fixes
Error: Input file is missing
The file path provided does not exist or is not accessible.
fix
Ensure the file exists and the path is correct. Use absolute paths or resolve relative paths with `path.resolve()`.
TypeError: Cannot read property 'width' of undefined
The input buffer or file is not a valid image/video format.
fix
Check the input format. Must be one of: jpeg, png, gif, webp, svg, mp4. For videos, ensure sharp is installed.
Error: sharp is not installed
Sharp dependency missing. Required for video and some image processing.
fix
Run `npm install sharp` to install sharp.
TypeError: Class constructor Sticker cannot be invoked without 'new'
Called Sticker as a function instead of with new keyword.
fix
Use `new Sticker(...)` instead of `Sticker(...)`.
Upgrade
Version history
4.4.4latest on npm
Audit
Dependencies
sharprequiredImage processing library used for resizing, cropping, and converting to WebP
file-typerequiredDetects input file type to handle images vs videos
@jimp/customoptionalAlternative image processing when sharp is not available
Agent activity
32 hits · last 30 days
node
28
OpenAI (training)
1
Resources
wa-sticker-formatter — npm install wa-sticker-formatter · libregistry