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-remove

v2.0.0

Published

Fast AI-powered background removal - instant transparent backgrounds

Readme

bg-remove

Fast AI-powered background removal - instant transparent backgrounds

A lightning-fast NPM package that removes backgrounds from images using advanced algorithms. Get transparent backgrounds in seconds, not minutes. Perfect for e-commerce, portraits, and any image processing workflow.

✨ Features

  • Ultra-fast processing - Instant results with optimized algorithms
  • 🔍 Transparent backgrounds only - Clean, simple output
  • 🧠 Multiple AI algorithms - Choose the best approach for your needs
  • 📸 Multiple formats - Supports JPG, PNG, WebP, URLs
  • 🎛️ Quality control - Fast, balanced, or high quality modes
  • 🔄 Batch processing - Process multiple images at once
  • 📦 Lightweight - No heavy AI models to download

📦 Installation

npm install bg-remove

🚀 Quick Start

const { removeBackground } = require('bg-remove');
const fs = require('fs');

// Remove background from an image
async function example() {
  const result = await removeBackground('input.jpg');
  
  // Save the transparent image
  fs.writeFileSync('output.png', result.data);
  
  console.log(`✅ Background removed! Size: ${result.width}x${result.height}`);
}

example();

📖 API Reference

removeBackground(input, options?)

Removes the background from an image and returns a transparent PNG.

Parameters:

  • input (string | Buffer) - Image file path, URL, or Buffer
  • options (object, optional) - Processing options

Options:

  • quality ('fast' | 'balanced' | 'high') - Processing quality (default: 'fast')
  • algorithm ('ultra-fast' | 'instant' | 'color-similarity' | 'edge-detection' | 'smart-detection') - Algorithm to use (default: 'ultra-fast')

Returns:

  • Promise<ProcessingResult> - Object with image data and metadata

Example:

const result = await removeBackground('photo.jpg', {
  quality: 'high',
  algorithm: 'instant'
});

removeBackgroundBatch(inputs, options?)

Process multiple images in batch.

Parameters:

  • inputs (Array<string | Buffer>) - Array of image inputs
  • options (object, optional) - Processing options

Returns:

  • Promise<ProcessingResult[]> - Array of processing results

Example:

const results = await removeBackgroundBatch([
  'photo1.jpg',
  'photo2.png',
  'photo3.webp'
]);

results.forEach((result, index) => {
  fs.writeFileSync(`output-${index}.png`, result.data);
});

🎯 Use Cases

  • E-commerce - Product photos with transparent backgrounds
  • Profile pictures - Remove backgrounds from portraits
  • Logos - Clean logo extraction
  • Design assets - Prepare images for graphic design
  • Automation - Batch process images in workflows

⚙️ Algorithm Options

  • ultra-fast - Lightning fast processing, good for real-time applications (default)
  • instant - Very fast with better quality than ultra-fast
  • color-similarity - Fast color-based background detection
  • edge-detection - Advanced edge detection for complex backgrounds
  • smart-detection - Combines multiple approaches for best results

🎛️ Quality Settings

  • fast - Quick processing, good for batch operations (default)
  • balanced - Good quality with reasonable speed
  • high - Best quality, slower processing

🔧 Advanced Usage

TypeScript Support

import { removeBackground, ProcessingResult } from 'bg-remove';

const result: ProcessingResult = await removeBackground('image.jpg');

Error Handling

try {
  const result = await removeBackground('image.jpg');
  console.log('Success!', result);
} catch (error) {
  console.error('Failed to remove background:', error.message);
}

Processing Large Images

// For large images, use 'fast' quality for better performance
const result = await removeBackground('large-image.jpg', { 
  quality: 'fast' 
});

📊 Performance

Ultra-Fast Algorithm (Default)

  • Small images (< 500KB): ~1-3 seconds
  • Medium images (500KB - 2MB): ~3-6 seconds
  • Large images (> 2MB): ~6-10 seconds

Instant Algorithm

  • Small images (< 500KB): ~2-4 seconds
  • Medium images (500KB - 2MB): ~4-8 seconds
  • Large images (> 2MB): ~8-15 seconds

Performance varies based on image complexity, size, and algorithm choice. All algorithms provide transparent backgrounds only.

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

📄 License

MIT License - see LICENSE file for details.

🙋‍♂️ Support

If you have any questions or issues, please open an issue on GitHub.


Made with ❤️ for simple background removal