Coder Social home page Coder Social logo

sticker-maker's Introduction

@shibam/sticker-maker

@shibam/sticker-maker is a lightweight utility library designed for converting images and videos into stickers while allowing customization of metadata. you don't have to download ffmpeg in terminal. It supports various input types and ensures high-quality sticker conversion. This module has minimal dependencies, ensuring efficient performance. If you encounter any issues, please feel free to open an issue. However, please check if a similar issue has already been reported before creating a new one. Happy Coding (⁠≧⁠▽⁠≦⁠).

Sticker Class

The Sticker class is a utility for converting images and videos into sticker format, with options for metadata customization and manipulation.

Installation

You can install the package using npm:

npm install @shibam/sticker-maker

Usage

Here's how you can use the Sticker class:

import fs from "fs";
import { Readable } from "stream";
import { Sticker, StickerTypes } from "@shibam/sticker-maker";

// Example 1: Create a new sticker instance and convert to buffer
const sticker = new Sticker("path/to/image.png", {
  pack: "My Sticker Pack",
  author: "Shibam",
  id: "123467890",
  category: ['😂','😹'],
  type: StickerTypes.DEFAULT,
  quality: 30,
});

try {
  const buffer = await sticker.toBuffer();
  console.log("Sticker converted to buffer:", buffer);
} catch (error) {
  console.error("Error converting sticker to buffer:", error);
}

// Example 2: Create a new sticker instance and convert to file
const sticker2 = new Sticker("path/to/another/image.png", {
  pack: "Another Sticker Pack",
  author: "John Doe",
  id: "987654321",
  category: ['😊','👍'],
  type: StickerTypes.CIRCLE,
  quality: 50,
});

try {
  await sticker2.toFile("path/to/output.webp");
  console.log("Sticker converted and saved to file successfully.");
} catch (error) {
  console.error("Error converting sticker to file:", error);
}

Class: Sticker

Constructor

new Sticker(data: Buffer | string | Readable, metaInfo?: Partial<MetaDataType>)
  • data: Input data for the sticker. Can be a Buffer, file path as a string, or Readable stream.
  • metaInfo (optional): Metadata about the sticker.

Methods

toBuffer(): Promise<Buffer>

Converts input data to a Buffer containing the converted sticker content.

toFile(outputPath: string): Promise<void>

Converts input data and writes the converted sticker to a file at outputPath.

changeMetaInfo(newMetaInfo: Partial<any>): Promise<any | undefined>

Updates metadata information with newMetaInfo and applies changes to the sticker.

extractMetaData(data: Buffer): Promise<any>

Extracts metadata from data and returns the extracted information.

Types

StickerTypes

An enum specifying different types of stickers:

enum StickerTypes {
  DEFAULT,
  CIRCLE,
  SQUARE,
}

License

This package is licensed under the MIT License.

Contributing

Contributions are welcome. Feel free to open issues or submit pull requests on GitHub.


This README provides an overview of the Sticker class functionalities, installation instructions, examples of usage, information about types used, and guidelines for contributing to the project. Adjust paths and additional details based on your actual implementation and repository setup.

sticker-maker's People

Contributors

shibamdey69 avatar

Stargazers

RA_ONE  avatar  avatar GURU SENSEI avatar Debanjan Das avatar Alι Aryαɴ avatar

Watchers

 avatar

Forkers

aliaryantech

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.