Gathering detailed insights and metrics for @laxeder/wa-sticker
Gathering detailed insights and metrics for @laxeder/wa-sticker
Gathering detailed insights and metrics for @laxeder/wa-sticker
Gathering detailed insights and metrics for @laxeder/wa-sticker
npm install @laxeder/wa-sticker
Typescript
Module System
Node Version
NPM Version
TypeScript (100%)
Total Downloads
1,723
Last Day
8
Last Week
20
Last Month
60
Last Year
656
MIT License
7 Commits
1 Watchers
1 Branches
1 Contributors
Updated on Apr 27, 2023
Latest Version
4.4.5
Package Id
@laxeder/wa-sticker@4.4.5
Unpacked Size
45.16 kB
Size
10.93 kB
File Count
29
NPM Version
10.2.3
Node Version
20.10.0
Published on
Jan 21, 2024
Cumulative downloads
Total Downloads
Last Day
33.3%
8
Compared to previous day
Last Week
25%
20
Compared to previous week
Last Month
-57.7%
60
Compared to previous month
Last Year
-27.9%
656
Compared to previous year
Wa-Sticker-Formatter is a simple tool which allows you to create and format WhatsApp Stickers.
1> npm i wa-sticker-formatter
Wa-Sticker-Formatter provides two ways to create stickers. The paramers are the same for both.
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.
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).
Before using the library, you need to import it.
1import { Sticker, createSticker, StickerTypes } from 'wa-sticker-formatter' // ES6 2// const { Sticker, createSticker, StickerTypes } = require('wa-sticker-formatter') // CommonJS
Sticker
constructor (Recommended)1const sticker = new Sticker(image, {
2 pack: 'My Pack', // The pack name
3 author: 'Me', // The author name
4 type: StickerTypes.FULL, // The sticker type
5 categories: ['🤩', '🎉'], // The sticker category
6 id: '12345', // The sticker id
7 quality: 50, // The quality of the output file
8 background: '#000000' // The sticker background color (only for full stickers)
9})
10
11const buffer = await sticker.toBuffer() // convert to buffer
12// or save to file
13await sticker.toFile('sticker.webp')
14
15// or get Baileys-MD Compatible Object
16conn.sendMessage(jid, await sticker.toMessage())
17
You can also chain methods like this:
1const buffer = await new Sticker(image) 2 .setPack('My Pack') 3 .setAuthor('Me') 4 .setType(StickerTypes.FULL) 5 .setCategories(['🤩', '🎉']) 6 .setId('12345') 7 .setBackground('#000000') 8 .setQuality(50) 9 .toBuffer()
The image
(first parameter) can be a Buffer, URL, SVG string, or File path.
1const sticker = new Sticker(`
2 <svg xmlns="http://www.w3.org/2000/svg" width="512" height="512" viewBox="0 0 512 512">
3 <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" />
4 </svg>
5`, { author: 'W3' })
createSticker
function1const buffer = await createSticker(buffer, options) // same params as the constructor 2// NOTE: `createSticker` returns a Promise of a Buffer
The following options are valid:
1interface IStickerConfig { 2 /** Sticker Pack title*/ 3 pack?: string 4 /** Sticker Pack Author*/ 5 author?: string 6 /** Sticker Pack ID*/ 7 id?: string 8 /** Sticker Category*/ 9 categories?: Categories[] 10 /** Background */ 11 background?: Sharp.Color 12 /** Sticker Type */ 13 type?: StickerTypes | string 14 /* Output quality */ 15 quality?: number 16}
Sticker types are exported as an enum.
1enum StickerTypes { 2 DEFAULT = 'default', 3 CROPPED = 'crop', 4 FULL = 'full', 5 CIRCLE = 'circle, 6 ROUNDED = 'rounded' 7} 8
Background can be a hex color string or a sharp color object.
1{ 2 "background": "#FFFFFF" 3}
or
1{ 2 "background": { 3 "r": 255, 4 "g": 255, 5 "b": 255, 6 "alpha": 1 7 } 8}
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.
The text on bold is the pack title and the rest is the author. This is actually Exif Metadata embedded in the WebP file.
This is an array of Emojis. Learn More
To extract the metadata from the WebP file, you can use the extractMetadata()
function.
1import { extractMetadata, Sticker } from 'wa-sticker-formatter' 2import { readFileSync } from 'fs' 3 4const sticker = readFileSync('sticker.webp') 5let metadata = await extractMetadata(sticker) // { emojis: [], 'sticker-pack-id': '', 'sticker-pack-name': '', 'sticker-author-name': '' } 6 7// or use the static method from the Sticker class 8metadata = await Sticker.extractMetadata(sticker) 9
Esse é um fork de Wa Sticker que corrige erros!!
No vulnerabilities found.
No security vulnerabilities found.