stickers-formatter
v0.0.1
Published
Sticker Creator for WhatsApp
Maintainers
Readme
Stickers-Formatter
Create and format WhatsApp Stickers with ease.
A feature-rich fork of wa-sticker-formatter
✨ Features
- 🖼️ Supports static images, GIFs, and Videos (animated WebP output)
- 🎨 Custom backgrounds, types, and categories
- 🔗 Fluent method chaining API
- 📦 Baileys-MD compatible output
- 🔍 Metadata extraction from existing stickers
- 📐 Multiple sticker types: Default, Crop, Full, Circle, Rounded
- 🖋️ SVG input support
📦 Installation
npm i stickers-formatter🚀 Quick Start
import { Sticker, StickerTypes } from 'stickers-formatter'
const sticker = new Sticker('./image.png', {
pack: 'My Pack',
author: 'Me',
type: StickerTypes.FULL,
})
const buffer = await sticker.toBuffer()📥 Import
import { Sticker, createSticker, StickerTypes } from 'stickers-formatter' // ES6
// const { Sticker, createSticker, StickerTypes } = require('stickers-formatter') // CommonJS📖 Usage
Stickers-Formatter provides two ways to create stickers — the Sticker class and the createSticker function. Both accept the same parameters:
| Parameter | Type | Description |
|-----------|------|-------------|
| image | Buffer \| string | Buffer, URL, SVG string, or file path. GIFs and videos produce animated WebP. |
| options | IStickerOptions | Configuration object (see Options) |
🏗️ Using the Sticker Class (Recommended)
const sticker = new Sticker(image, {
pack: 'My Pack',
author: 'Me',
type: StickerTypes.FULL,
categories: ['🤩', '🎉'],
id: '12345',
quality: 50,
background: '#000000'
})
const buffer = await sticker.toBuffer()
await sticker.toFile('sticker.webp')
sock.sendMessage(jid, await sticker.toMessage())Method Chaining
const buffer = await new Sticker(image)
.setPack('My Pack')
.setAuthor('Me')
.setType(StickerTypes.FULL)
.setCategories(['🤩', '🎉'])
.setID('12345')
.setBackground('#000000')
.setQuality(50)
.toBuffer()SVG Input
const sticker = new Sticker(`
<svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512">
<path d="M256 0C114.6 0 0 114.6 0 256s114.6 256 256 256 256-114.6 256-256S397.4 0 256 0z" fill="#ff0000" />
</svg>
`, { author: 'Me', pack: 'SVG Pack' })⚡ Using the createSticker Function
const buffer = await createSticker(image, options)Returns a
Promise<Buffer>— useful for functional-style code.
⚙️ Options
interface IStickerOptions {
pack?: string
author?: string
id?: string
categories?: Categories[]
background?: Sharp.Color
type?: StickerTypes | string
quality?: number
}| Option | Type | Default | Description |
|--------|------|---------|-------------|
| pack | string | '' | Sticker pack title |
| author | string | '' | Sticker pack author |
| id | string | auto-generated | Unique sticker pack ID |
| categories | string[] | undefined | Array of emojis for categorization |
| background | string \| object | transparent | Hex string or RGBA object |
| type | StickerTypes | DEFAULT | How the image is fitted |
| quality | number (0–100) | 100 | Output WebP quality |
📐 Sticker Types
enum StickerTypes {
DEFAULT = 'default',
CROPPED = 'crop',
FULL = 'full',
CIRCLE = 'circle',
ROUNDED = 'rounded'
}| Type | Description |
|------|-------------|
| DEFAULT | Standard WhatsApp sticker sizing |
| CROPPED | Crops the image to fit |
| FULL | Fits the full image with optional background |
| CIRCLE | Circular crop |
| ROUNDED | Rounded corners |
🎨 Background
The background option accepts a hex string or a Sharp RGBA object.
background: '#FFFFFF'background: {
r: 255,
g: 255,
b: 255,
alpha: 1
}Background is only applied when using
StickerTypes.FULL.
🔍 Metadata
WhatsApp stickers embed metadata (author, pack name, category) directly into the WebP file as Exif data.
Bold text = Pack title | Regular text = Author name
Sticker Category
Categories are arrays of emojis embedded in the sticker metadata. Learn more →
Extracting Metadata
import { extractMetadata, Sticker } from 'stickers-formatter'
import { readFileSync } from 'fs'
const file = readFileSync('sticker.webp')
const metadata = await extractMetadata(file)
// {
// emojis: [],
// 'sticker-pack-id': '',
// 'sticker-pack-name': '',
// 'sticker-pack-publisher': ''
// }
const metadata2 = await Sticker.extractMetadata(file)🤝 Contributing
Contributions, issues and feature requests are welcome! Feel free to open an issue or submit a pull request.
📄 License
Distributed under the MIT License. See LICENSE for more information.
Made with ❤️ — Thanks for using Stickers-Formatter!
