Skip to content

comontes/wa-sticker-formatter

 
 

Repository files navigation

wsf

Wa-Sticker-Formatter

Wa-Sticker-Formatter is a simple tool which allows you to create and format WhatsApp Stickers.

NPM CodeFactor NPM

Installation

> npm i wa-sticker-formatter

Metadata

Before getting started, you need to know some basic information about WhatsApp Sticker Metadata.

In WhatsApp, stickers have their own metadata embedded in the WebP file. They hold info like the author, the title or pack name, the category.

Let's go through them one by one.

1. Author and Pack Title

metadata

The text on bold is the pack title and the rest is the author. This is actually Exif Metadata embedded in the WebP file.

2 Sticker Category

This is an array of Emojis. Learn More

Usage

Wa-Sticker-Formatter provides two ways to create stickers. The paramers are the same for both.

First is the Buffer, URL or File path of static image, GIF or Video. The second is the options. GIFs and Videos will output an animated WebP file.

Sticker options are:

pack - The pack name.
author - The author name.
type - Value from StickeTypes enum (exported). Can be 'crop' or 'full' or undefined (default).
categories - The sticker category. Can be an array of Emojis or undefined (default).
id - The sticker id. If this property is not defined, it will be generated.

Examples

1. Using the Sticker Class

Example:

import { Sticker } from 'wa-sticker-formatter'
// const { Sticker } = require('wa-sticker-formatter')

const image = 'https://c.tenor.com/WZBvSgw5JMgAAAAC/watson-amelia-amelia-watson.gif'

(async () => {
    const stickerMetadata = {
        type: StickerTypes.CROPPED,
        pack: 'watson',
        author: 'amelia',
        categories: [
            '🌹'
        ]
    }
    const sticker = await new Sticker(image, stickerMetadata).build()
})()

2. Using the createSticker function

import { createSticker, StickerTypes } from 'wa-sticker-formatter'
// const { createSticker } = require('wa-sticker-formatter')

const image = 'https://c.tenor.com/WZBvSgw5JMgAAAAC/watson-amelia-amelia-watson.gif' // Supports Buffer, URLs and filepath of Static Images, GIFs and Videos

(async () => {
    const stickerMetadata = {
        type: StickerTypes.FULL, //can be full or crop
        pack: 'watson',
        author: 'amelia',
        categories: [
            '🌹'
        ]
    }
    const sticker = await createSticker(image, stickerMetadata)
})()

Packages

No packages published

Languages

  • TypeScript 97.7%
  • JavaScript 2.3%