Sticker Creator for WhatsApp

Overview
WATCIKER

WA-STICKER-FORMATTER

Whatsapp Sticker Creator/Formatter!



Installation

> npm i wa-sticker-formatter

Usage

Importing

💛 JavaScript

const WSF = require('wa-sticker-formatter')

💙 TypeScript

import * as WSF from 'wa-sticker-formatter'

Raw Functions

Add Metadata to Webp

const webpWithMetadata = await WSF.setMetadata('Pack Title', 'Author', image.webp) //returns the webp buffer with metadata

Create an exif metadata file

const exif = createExif('Pack', 'Author', 'filename') //returns the filename with ".exif"

Creating Sticker

Note: The following methods need imageMagick Legacy CLI tools to be installed in your system

Regular Sticker

const sticker = new WSF.Sticker('image.png', {})
await sticker.build()
const sticBuffer = await sticker.get()

Non-streched sticker

const image = 'https://example.com/example.png' 
const sticker = new WSF.Sticker(image, { crop: false })
await sticker.build()
const sticBuffer = await sticker.get()

Non-cropped Animated sticker

const sticker = new WSF.Sticker('./image.mp4', { crop: false, animated: true })
await sticker.build()
const sticBuffer = await sticker.get()

Sticker with Pack and Author Name

const sticker = new WSF.Sticker('https://example.com/sample.mp4', { crop: false, animated: true, pack: 'Pack', author: 'AUTHOR' })
await sticker.build()
const sticBuffer = await sticker.get()

Saving/Sending

Saving to File

fs.writeFile('sticker.webp', sticBuffer)

Sending With Baileys

conn.sendMessage(jid, sticBuffer, MessageType.sticker)

Sending With Open-Wa/Wa-Automate-Nodejs

client.sendRawWebpAsSticker(jid, sticBuffer.toString('base64'))
Comments
  • sticker from video or gif is generated with a strange effect

    sticker from video or gif is generated with a strange effect

    the sticker looks like the example below:

    ezgif com-gif-maker

    any way to fix or avoid this weird effect?

    my code:

    const sticker = new Sticker(buffer, {
        pack: 'thierry', // The pack name
        author: 'bot thierry', // The author name
        type: StickerTypes.FULL, // The sticker type
        categories: ['🤩', '🎉'], // The sticker category
        id: '1234', // The sticker id
        quality: 50, // The quality of the output file
    })
    await sticker.toFile('./static/sticker.webp')
    
    opened by erickythierry 3
  • Possible Bug

    Possible Bug

    Here in this Function https://github.com/AlenSaito1/wa-sticker-formatter/blob/b4eb0685dd3548d08845197cb9e1c7118ed79c88/src/lib/convert.ts#L8

    Following Code Uses Recursion. I don't exactly understand, what it's doing but this might be the source of infinite ffmpeg loop

    const convert = async (data: Buffer, mime: string, type: 'crop' | 'full' | 'default' = 'default'): Promise<Buffer> => {
        const isVideo = mime.startsWith('video')
        const image = isVideo ? await videoToGif(data) : data
        if ((isVideo || mime.includes('gif')) && type === 'crop') {
            const filename = `${tmpdir()}/${Math.random().toString(36)}.webp`
            await writeFile(filename, image)
            return convert(await crop(filename), 'image/webp', 'default')
        }
    
    opened by PrajjwalDatir 3
  • Error: cannot find ffmpeg

    Error: cannot find ffmpeg

    When I'm going to make a sticker in mp4 format this error appears in the console

    Error: Cannot find ffmpeg
    

    Even though I already installed ffmpeg with

    npm i fluent-ffmpeg
    
    opened by AdamRoyn 2
  • Crop problem in still Images

    Crop problem in still Images

    I checked cropping static Image with new WSF.Sticker(buffer,{crop: true}); the Image was stretched and same when used with animated:true for gifs sticker returned with perfectly centerCropped Image.

    crop:true is stretching/squeezing static Images and centerCropping gifs I need to centerCrop static images too any workaround to achieve this ?

    opened by ni3mumbaikar 2
  • WebpMux error on termux - Syntax error:

    WebpMux error on termux - Syntax error: ")" unexpected

    I'm running this piece of code in my script that creates a WebP to send to someone as a sticker.

    const webpWithMetadata = await WSF.setMetadata('O melhor robo', 'Jarvis', ran) //returns the webp buffer with metadata

    But when I run this code I get this error:

    errowebpmux

    PS: I'm using termux on my android phone...

    opened by guiguicdd 2
  • Error in Sticker formatter of xre

    Error in Sticker formatter of xre

    A simple problem has surfaced since last few days, as my xre...which is being hosted on cloud through free heroku Isn't being able to convert animated gif stickers properly, i mean it's creating a sticker but that's not the gif but a still image into sticker, also the processing is slow (taking around 50-60seconds). I know this might be because of Cloud platform being weak to handle all this nodes but...I wish it could be fixed. Thank you!

    opened by AB1RZ9 2
  • any way to just set the exif data?

    any way to just set the exif data?

    I'm using version 3.6 to just define the pack and author of the sticker. I have my own function that converts to webp with a nice performance. is there any way to only use this functionality in the most current version of the lib?

    I need the most current function because it runs on ARM machines

    opened by erickythierry 1
  • Cannot read properties of undefined (reading 'toString')

    Cannot read properties of undefined (reading 'toString')

    i try to extractMetadata a sticker without packname and author , but it says error like this

    TypeError: Cannot read properties of undefined (reading 'toString')
        at C:\Users\Administrator\nganu\node_modules\wa-sticker-formatter\dist\extractMetadata.js:22:27
        at Generator.next (<anonymous>)
        at fulfilled (C:\Users\Administrator\nganu\node_modules\wa-sticker-formatter\dist\extractMetadata.js:5:58)
        at processTicksAndRejections (node:internal/process/task_queues:96:5)
    

    can we handle this with empty result, like

    {
        'emojis': [],
        'sticker-pack-id': '',
        'sticker-pack-name': '',
        'sticker-pack-publisher': '',
    }
    

    sorry for my bad english 😄

    opened by Gimenz 1
  • Animated as option!

    Animated as option!

    If you use this with webp file to put metadata and send the animated sticker works great, but if you check the sticker message it is false to isAnimated.

    animated: boolean

    opened by Iucasmaia 1
  • Fix Full + Animated Stickers

    Fix Full + Animated Stickers

    This PR fixes the issue with animated stickers with full type

    Example

    Code

    const sticker = new Sticker(image, {
        type: StickerTypes.FULL, // 'full'
    })
    

    Results

    Output
    Before After

    Image Used

    This PR will be merged after https://github.com/lovell/sharp/pull/2789 has been merged and published

    opened by AlenVelocity 0
  • Fix braces issue  JSON extract EXIF

    Fix braces issue JSON extract EXIF

    This is an example were it is not returning the object properly. With this error: SyntaxError: Unexpected token ☺ in JSON at position 1

    and this result on "const exif": II☺AW{☺▬{"sticker-pack-id":"com.snowcorp.stickerly.android.stickercontentprovider f2c83f90-25c6-4b45-9866-1f6bd657616f","sticker-pack-name":"stickerman","sticker-pack-publisher":"Sticker.ly * dudaxd1212","android-app-store-link":"https://play.google.com/store/apps/details?id=com.snowcorp.stickerly.android","ios-app-store-link":"https://itunes.apple.com/app/id1458740001?mt=8"}

    So I made this correction that fixies this issue and gets the rigth start braces.

    opened by guiguicdd 0
  • video to sticker giving error

    video to sticker giving error

    not able to convert video to a sticker @AlenSaito1

    handleExit(new Error('ffmpeg exited with code ' + code)); ^ Error: ffmpeg exited with code 1 at ChildProcess. (D:\Giga\Java Script\I-BOT\node_modules\fluent-ffmpeg\lib\processor.js:182:22) at ChildProcess.emit (events.js:315:20) at ChildProcess.EventEmitter.emit (domain.js:486:12) at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12) error Command failed with exit code 1.

    opened by chauhanshivam079 5
  • Something went wrong when installing the

    Something went wrong when installing the "sharp" module

    Something went wrong installing the "sharp" module

    Error relocating /root/myroot/node_modules/sharp/build/Release/../.././vendor/8.11.3/linuxmusl-x64/lib/libvips-cpp.so.42: _ZNSt7__cxx1119basic_ostringstreamIcSt11char_traitsIcESaIcEEC1Ev: symbol not found

    Possible solutions:

    • Install with the --verbose flag and look for errors: "npm install --ignore-scripts=false --verbose sharp"
    • Install for the current runtime: "npm install --platform=linux --arch=x64 sharp"
    • Consult the installation documentation: https://sharp.pixelplumbing.com/install
    opened by MrJoka-Thejaka 2
Releases(v4.3.0)
  • v4.3.0(Feb 5, 2022)

    What's Changed?

    • feat(): convert examples to ts and add new examples for circle type. Fixes #23 (75f889f)
    • deps(dev): add ts-node (a9ddd6c)
    • deps(): update sharp (03f9974)
    • chore(): update woorkflows (0cb8de7)
    • chore(): update workflows (89ea6e6)
    • Merge branch 'master' of https://github.com/AlenSaito1/wa-sticker-formatter (c28dfda)
    • Merge branch 'master' of https://github.com/AlenSaito1/wa-sticker-formatter (44e22e3)
    • chore(): update workflows (b516d89)
    • chore(): update workflows (55ef21b)
    • fix(): extractMetadata throwing error #33 (ebdded8)
    • Merge branch 'master' of https://github.com/AlenSaito1/wa-sticker-formatter (1f61a6b)
    • feat(): circle type #32 (ac5577a)
    • feat(): circle type #14 (18eada9)
    • Merge pull request #29 from AlenSaito1/fix-animated (6ce22c3)
    • chore(): update sharp (02053e4)
    • chore(): update examples (7f7825f)
    • Create FUNDING.yml (1099f93)
    • chore(): regen package-lock.json (d0aa0f6)
    • chore(): update convert() (6bcea22)
    • deps(): use github:kleisauke/sharp#vips-thumbnail (01f631d)
    • chore(): update README (a0b2879)
    • feat(): new static method (ee52e3f)

    Notable Changes

    • Fix Full + Animated Stickers by @AlenSaito1 in https://github.com/AlenSaito1/wa-sticker-formatter/pull/29

    Full Changelog: https://github.com/AlenSaito1/wa-sticker-formatter/compare/v4.2.0...v4.3.0

    Source code(tar.gz)
    Source code(zip)
  • v4.2.0(Nov 18, 2021)

    What's Changed

    • chore(): update readme (35a47ea)
    • feat(): add Sticker.toMessage() method (eefd762)
    • style(): run prettier (e032a17)
    • chore(): update README (1bf6f45)
    • chore(): update tests (e369cc4)
    • feat(): svg support. Fixes #25 (76048c1)
    • deps(): update shrap (015f2dc)
    • Merge branch 'master' of https://github.com/AlenSaito1/wa-sticker-formatter (1b14fea)
    • options(): convert() now takes StickerOptions as it's 2nd param (c9f5796)
    • Merge pull request #24 from AlenSaito1/master-cf-autofix (c4cb1be)
    • [CodeFactor] Apply fixes (70259c2)
    • config(): prefer json (059e9d3)

    Full Changelog: https://github.com/AlenSaito1/wa-sticker-formatter/compare/v4.1.2...v4.2.0

    Source code(tar.gz)
    Source code(zip)
  • v4.1.2(Nov 8, 2021)

    • deps(): add rimraf (3613c6a)
    • docs(): update README (f9f181f)
    • feat(): add more chainable methods (bfd5a04)
    • feat(): better JSDoc (cfed3af)
    • style(): run prettier (96b2e88)
    • feat(): add .toBuffer() property to Sticker constructor (a128c24)
    • config(): setup release-it (82d85b2)
    • deps() (2aee0ce)
    • config(): update scripts (07d8a69)
    • deps(): add version-select (33575bd)
    • deps(): fix vulnerabilities (288bd3a)
    • deps(): add class-validator (d584747)
    • chore(): update examples (263395e)
    • chore(): ad JSDoc for extractMetadata (6598dec)
    • chore(): run prettier (b8d0730)
    Source code(tar.gz)
    Source code(zip)
  • 4.1.1(Oct 28, 2021)

    What's new

    • Ability to add a custom background for full type sticker
    • Better JSDoc and tooling

    Full Changelog: https://github.com/AlenSaito1/wa-sticker-formatter/compare/4.1.0...4.1.1

    Source code(tar.gz)
    Source code(zip)
  • 4.1.0(Oct 28, 2021)

    What's Changed

    • feat(): add extractMetadata() to extract metadata from a WebP file
    • feat(): add new methods setAuthor(), setCategories(), setPack() and seID to Sticker for more customizability

    New Contributors

    • @mukhlisakbr made their first contribution in https://github.com/AlenSaito1/wa-sticker-formatter/pull/20

    Full Changelog: https://github.com/AlenSaito1/wa-sticker-formatter/compare/v4.0.14...4.1.0

    Source code(tar.gz)
    Source code(zip)
  • v4.0.12(Sep 17, 2021)

Owner
Alen Yohannan
Well, in that case...
Alen Yohannan
Qt Based WhatsApp Client

WhatSie WhatSie is Light, feature rich WhatsApp web client written in Qt and not on Electron. A simple & beautiful desktop client for WhatsApp Web. Ch

Keshav Bhatt 691 Dec 27, 2022
Simple Notepad App. C++ with Qt Creator

Notepad How to run the app? To run this application: You have to have installed latest Visual C++ Redistributable for Visual Studio 2015, 2017 and 201

Yashmerino 3 Oct 27, 2022
Real-time GUI layout creator/editor for Dear ImGui

ImStudio Real-time GUI layout creator/editor for Dear ImGui Inspired by Code-Building/ImGuiBuilder Features Drag edit Property edit Covers most of the

null 303 Jan 9, 2023
An implemented GUI of Conway's Game of Life created using QT Creator.

Conways-Game-of-Life This is my newly implemented GUI of Conway's Game of Life created using QT Creator! Interactions: -The 'Step' button allows you t

null 1 Nov 16, 2021
File Format Definition. Creator, and Player

Wusik SPXe Created by William Kalfelz @ Wusik.com (c) 2021 Open-Source File Format Definition and Editor This Project is in ALPHA stage. The file form

Wusik Dot Com 5 Oct 18, 2022
Enhanced CMake Project Manager plugin for Qt Creator

CMakeProjectManager2 Alternative CMake support for Qt Creator. Main differents from original CMakeProject plugin: Project file list readed from file s

Alexander Drozdov 71 Nov 20, 2022
GB Studio is a quick and easy to use retro adventure game creator for Game Boy available for Mac, Linux and Windows

GB Studio is a quick and easy to use retro adventure game creator for Game Boy available for Mac, Linux and Windows

Chris Maltby 6.8k Jan 8, 2023
Windows file startup creator write in c++

startup-creator Language Simple program written in c++, for you to place your programs at windows startup. ?? Requirements Latest Mingw-64 or Mingw-32

Dio brando 6 Jan 22, 2022