Socket
Book a DemoInstallSign in
Socket

@devadri/create-sticker

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@devadri/create-sticker

Library that adds a sticker effect to images with transparent backgrounds

latest
Source
npmnpm
Version
1.1.0
Version published
Maintainers
0
Created
Source

@devadri/create-sticker

Library that adds a sticker effect to images with transparent backgrounds.

Header image

This code was made thanks to this Stack Overflow answer made by the user markE.

Tested with .png, .webp and .jpg.

Customize: stroke color, stroke thickness, fill holes and image padding.

It uses HTML Canvas, so it only works in the browser (and not in Node.js).

Install

Browser

<script src="https://unpkg.com/@devadri/create-sticker@{{ version }}/bundle.iife.js"></script>

npm

npm install @devadri/create-sticker

Usage

Browser

<script src="https://unpkg.com/@devadri/create-sticker@1.1.0/dist/bundle.iife.js"></script>
<script>
  async function modifyImage(img) {
    const options = {
      strokeWidth: 20,
      strokeColor: "black",
      padding: 20,
      fillHoles: true
    }
    const stickerImgSrc = await CreateSticker.createSticker(img.src, options);
    img.src = stickerImgSrc;
  }
</script>

ESM / TypeScript

import { createSticker, CreateStickerOptions } from '@devadri/create-sticker';

async function modifyImage(img) {
  const options: CreateStickerOptions = {
    strokeWidth: 20,
    strokeColor: "black",
    padding: 20,
    fillHoles: true
  }
  const stickerImgSrc = await createSticker(img.src, options);
  img.src = stickerImgSrc;
}

Default options

{
  "strokeWidth": 20,
  "strokeColor": "white",
  "padding": 1,
  "fillHoles": true
}

padding minimum values is 1.

Demo

Run the demo with the following commands:

npm run build
npm run demo

Screenshots

Demo screenshot 1 Demo screenshot 2 Demo screenshot 6 Demo screenshot 5 Demo screenshot 3 Demo screenshot 4 Demo screenshot 7

License

Unlicense license

Keywords

sticker

FAQs

Package last updated on 13 Aug 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.