New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@imgly/background-removal

Package Overview
Dependencies
Maintainers
7
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@imgly/background-removal

Background Removal in the browser

  • 0.1.0-rc1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.2K
increased by8.67%
Maintainers
7
Weekly downloads
 
Created
Source

Background Removal in the Web Browser

Getting Started

npm install @imgly/background-removal

or

yarn add @imgly/background-removal

Usage

import imgly_bg_remove from `@imgly/background-removal`

let image_src: ImageData | ArrayBuffer | Uint8Array | Blob | URL | string = ...;

imgly_bg_remove(image_src).then((blob: Blob) => {
  // result is a blob encoded as PNG.
  // It can be converted to an URL to be used as HTMLImage.src
  const url = URL.createObjectURL(blob);
})

Custom deployment

Currently, the wasm and onnx neural networks are served via unpkg. For production use, we advise to host them yourself. Therefore, copy all .wasm and .onnx files to your public path and reconfigure the library

cp node_modules/@imgly/background-removal/dist/*.wasm $PUBLIC_PATH
cp node_modules/@imgly/background-removal/dist/*.onnx $PUBLIC_PATH
import imgly_bg_remove, {Config} from `@imgly/background-removal`

const public_path = ... ; // the path assets are served from

let config: Config =  { 
  wasmPath: public_path, // path to the wasm files
  modelPath: public_path 
};

let image_src: ImageData | ArrayBuffer | Uint8Array | Blob | URL | string = ...;

imgly_bg_remove(image_src, config).then((blob: Blob) => {
  // result is a blob encoded as PNG.
  // It can be converted to an URL to be used as HTMLImage.src
  const url = URL.createObjectURL(blob);
})

FAQs

Package last updated on 20 Jun 2023

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc