Skip to content

GlobalTechInfo/stickers-formatter

Stickers-Formatter

Stickers-Formatter

Create and format WhatsApp Stickers with ease.

A feature-rich fork of wa-sticker-formatter

License Code Quality Downloads NPM Version


✨ 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.

Sticker metadata preview

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!