All Projects → AlenSaito1 → wa-sticker-formatter

AlenSaito1 / wa-sticker-formatter

Licence: MIT license
Sticker Creator for WhatsApp

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to wa-sticker-formatter

Sharp
High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
Stars: ✭ 21,131 (+35118.33%)
Mutual labels:  png, exif, webp, sharp
Metadata Extractor Dotnet
Extracts Exif, IPTC, XMP, ICC and other metadata from image, video and audio files
Stars: ✭ 518 (+763.33%)
Mutual labels:  png, exif, webp
Metadata Extractor
Extracts Exif, IPTC, XMP, ICC and other metadata from image, video and audio files
Stars: ✭ 1,972 (+3186.67%)
Mutual labels:  png, exif, webp
Optimise Images
Batch image resizer, optimiser and profiler using ImageMagick convert, OptiPNG, JpegOptim and optional ZopfliPNG, Guetzli and MozJPEG.
Stars: ✭ 64 (+6.67%)
Mutual labels:  png, webp
Isparta
APNG、WebP converter
Stars: ✭ 942 (+1470%)
Mutual labels:  png, webp
Format parser
file metadata parsing, done cheap
Stars: ✭ 46 (-23.33%)
Mutual labels:  png, exif
Libvips
A fast image processing library with low memory needs.
Stars: ✭ 6,094 (+10056.67%)
Mutual labels:  png, webp
sail
The missing small and fast image decoding library for humans (not for machines) ⛵ https://sail.software
Stars: ✭ 206 (+243.33%)
Mutual labels:  png, webp
Bimg
Go package for fast high-level image processing powered by libvips C library
Stars: ✭ 1,394 (+2223.33%)
Mutual labels:  png, webp
Next Img
A Next.js plugin for embedding optimized images.
Stars: ✭ 149 (+148.33%)
Mutual labels:  png, webp
video thumbnail
This plugin generates thumbnail from video file or URL. It returns image in memory or writes into a file. It offers rich options to control the image format, resolution and quality. Supports iOS and Android.
Stars: ✭ 159 (+165%)
Mutual labels:  png, webp
Is Animated
Checks if image is animated 🎞
Stars: ✭ 17 (-71.67%)
Mutual labels:  png, webp
Pixterm
Draw images in your ANSI terminal with true color
Stars: ✭ 782 (+1203.33%)
Mutual labels:  png, webp
Tiny Site
图片优化
Stars: ✭ 65 (+8.33%)
Mutual labels:  png, webp
Flyimg
Dockerized PHP7 application runs as a Microservice to resize and crop images on the fly. Get optimised images with MozJPEG, WebP or PNG using ImageMagick. Includes face detection, cropping, face blurring, image rotation and many other options. Abstract storage based on FlySystem in order to store images on any provider (local, AWS S3...).
Stars: ✭ 762 (+1170%)
Mutual labels:  png, webp
Lilliput
Resize images and animated GIFs in Go
Stars: ✭ 1,690 (+2716.67%)
Mutual labels:  png, webp
Imageprocessor
📷 A fluent wrapper around System.Drawing for the processing of image files.
Stars: ✭ 2,452 (+3986.67%)
Mutual labels:  png, webp
ipx
High performance, secure and easy to use image proxy based on Sharp and libvips.
Stars: ✭ 683 (+1038.33%)
Mutual labels:  webp, sharp
Sdwebimage
Asynchronous image downloader with cache support as a UIImageView category
Stars: ✭ 23,928 (+39780%)
Mutual labels:  png, webp
Optimizt
CLI image optimization tool
Stars: ✭ 594 (+890%)
Mutual labels:  png, webp
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

Usage

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

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

  2. 2nd Paramter, an object, Sticker Options accepts the following fields

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).
quality - The quality of the output file. Can be an integer from 0 to 100. Defaults to 100. id - The sticker id. If this property is not defined, it will be generated.
background - Background color in hexadecimal format or an RGBA Object. Defaults to undefined (transparent).

Import

Before using the library, you need to import it.

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

Using The Sticker constructor (Recommended)

const sticker = new Sticker(image, {
    pack: 'My Pack', // The pack name
    author: 'Me', // The author name
    type: StickerTypes.FULL, // The sticker type
    categories: ['🤩', '🎉'], // The sticker category
    id: '12345', // The sticker id
    quality: 50, // The quality of the output file
    background: '#000000' // The sticker background color (only for full stickers)
})

const buffer = await sticker.toBuffer() // convert to buffer
// or save to file
await sticker.toFile('sticker.webp')

// or get Baileys-MD Compatible Object
conn.sendMessage(jid, await sticker.toMessage())

You can also chain methods like this:

const buffer = await new Sticker(image)
    .setPack('My Pack')
    .setAuthor('Me')
    .setType(StickerTypes.FULL)
    .setCategories(['🤩', '🎉'])
    .setId('12345')
    .setBackground('#000000')
    .setQuality(50)
    .toBuffer()

The image (first parameter) can be a Buffer, URL, SVG string, or File path.

SVG Example

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 0zm0 464c-119.1 0-216-96.9-216-216S136.9 40 256 40s216 96.9 216 216-96.9 216-216 216z" fill="#ff0000" />
    </svg>
`, { author: 'W3' })

Using the createSticker function

const buffer = await createSticker(buffer, options) // same params as the constructor
// NOTE: `createSticker` returns a Promise of a Buffer

Options

The following options are valid:

interface IStickerConfig {
    /** Sticker Pack title*/
    pack?: string
    /** Sticker Pack Author*/
    author?: string
    /** Sticker Pack ID*/
    id?: string
    /** Sticker Category*/
    categories?: Categories[]
    /** Background */
    background?: Sharp.Color
     /** Sticker Type */
    type?: StickerTypes | string
    /* Output quality */
    quality?: number
}

Sticker Types

Sticker types are exported as an enum.

enum StickerTypes {
    DEFAULT = 'default',
    CROPPED = 'crop',
    FULL = 'full'
}

Background

Background can be a hex color string or a sharp color object.

{
    "background": "#FFFFFF"
}

or

{
    "background": {
        "r": 255,
        "g": 255,
        "b": 255,
        "alpha": 1
    }
}

Metadata

Here's some basic information about WhatsApp Sticker Metadata.

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

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

Extracting Metadata

To extract the metadata from the WebP file, you can use the extractMetadata() function.

import { extractMetadata, Sticker } from 'wa-sticker-formatter'
import { readFileSync } from 'fs'

const sticker = readFileSync('sticker.webp')
let metadata = await extractMetadata(sticker) // { emojis: [], 'sticker-pack-id': '', 'sticker-pack-name': '', 'sticker-author-name': '' }

// or use the static method from the Sticker class
metadata = await Sticker.extractMetadata(sticker)

Thanks for using Wa-Sticker-Formatter!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].