npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

bg-curve-remover

v1.0.1

Published

Pure JavaScript background remover with curve-aware alpha refinement for browser and Node.js.

Readme

bg-curve-remover

A pure JavaScript background remover for browser workflows.

bg-curve-remover removes image backgrounds using an in-house, browser-side extraction pipeline:

  • border color modeling
  • background flood-growth segmentation
  • curve/edge alpha softening
  • small artifact cleanup

Install

npm install bg-curve-remover

Quick Start (Browser)

import { removeBackgroundToObjectURL } from 'bg-curve-remover';

const input = document.querySelector('#file').files[0];
const resultUrl = await removeBackgroundToObjectURL(input);
document.querySelector('#preview').src = resultUrl;

Core API

removeBackground(input, options?)

Removes the background and returns a processed image object.

  • Browser usage: returns a Blob (PNG by default)
  • Input types: File, Blob, URL string
import { removeBackground } from 'bg-curve-remover';

const outputBlob = await removeBackground(file, {
  output: { type: 'image/png', quality: 0.98 },
  extraction: { edgeSoftness: 26, minSubjectRegion: 120 }
});

removeBackgroundToObjectURL(input, options?)

Convenience wrapper for browser previews.

  • Calls removeBackground(...)
  • Converts result Blob to URL.createObjectURL(...)
import { removeBackgroundToObjectURL } from 'bg-curve-remover';

const url = await removeBackgroundToObjectURL(file);
img.src = url;

Options

output

Output image configuration.

  • type: MIME type (recommended: image/png for transparency)
  • quality: compression quality (used where relevant)
{ output: { type: 'image/png', quality: 0.98 } }

extraction

Controls your in-house subject extraction pipeline.

  • borderSampleStep (default 2): border sampling stride for background color model
  • bgDistancePercentile (default 0.35): base threshold from color-distance distribution
  • bgGrowMultiplier (default 1.25): expansion factor when flood-filling background
  • minSubjectRegion (default 120): remove tiny foreground islands
  • edgeSoftness (default 26): feathering amount on extracted edges
{
  extraction: {
    borderSampleStep: 2,
    bgDistancePercentile: 0.35,
    bgGrowMultiplier: 1.25,
    minSubjectRegion: 120,
    edgeSoftness: 26
  }
}

This helps remove leftover stray pixels both outside and inside the subject region while preserving smoother edges.

Demo

Live demo (GitHub Pages):

Run demo locally:

npm install
npm run demo

Use in Your Project

Typical flow:

  1. User selects or drops image
  2. Call removeBackground(...)
  3. Show preview, upload output, or download PNG

Example (download):

const resultBlob = await removeBackground(file, {
  output: { type: 'image/png', quality: 0.98 }
});

const url = URL.createObjectURL(resultBlob);
const a = document.createElement('a');
a.href = url;
a.download = 'cutout.png';
a.click();
URL.revokeObjectURL(url);

Notes

  • First run may be slower while model assets are loaded.
  • PNG output is recommended for transparent backgrounds.
  • Complex hair/fur/translucent edges can still benefit from manual touch-up depending on source image quality.
  • This package does not call your backend services; extraction runs locally in-browser.

License

MIT