Skip to content
Go-based command-line tool for the remove.bg API
Branch: master
Clone or download
Latest commit b082bc9 May 13, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Adjust CircleCI workflow config Apr 25, 2019
bin Add build script Apr 30, 2019
cli
client Parse & notify JSON response errors Apr 29, 2019
fixtures Remove background from multiple files Apr 15, 2019
processor Fix skipping image bug Apr 29, 2019
.gitignore Add build instructions Apr 16, 2019
Gopkg.lock Display progress with structured logs Apr 26, 2019
Gopkg.toml Display progress with structured logs Apr 26, 2019
README.md Add download link to README May 13, 2019
main.go Initial CLI structure Apr 11, 2019

README.md

Go

CircleCI

Download

Download latest stable release (Windows, Mac, Linux)

CLI usage

removebg [options] <file>...

API key

To process images you'll need your remove.bg API key.

To use the API key for all requests you can export the following environment variable in your shell profile (e.g. ~/.bashrc / ~/.zshrc):

export REMOVE_BG_API_KEY=xyz

Alternatively you can specify the API key per command:

removebg --api-key xyz images/image1.jpg

Processing a directory of images

Saving to the same directory (default)

If you want to remove the background from all the PNG and JPG images in a directory, and save the transparent images in the same directory:

removebg images/*.{png,jpg}

Given the following input:

images/
├── dog.jpg
└── cat.png

The result would be:

images/
├── dog.jpg
├── cat.png
├── dog-removebg.png
└── cat-removebg.png

Saving to a different directory (--output-directory)

If you want to remove the background from all the PNG and JPG images in a directory, and save the transparent images in a different directory:

mkdir processed
removebg --output-directory processed originals/*.{png,jpg}

Given the following input:

originals/
├── dog.jpg
└── cat.png

The result would be:

originals/
├── dog.jpg
└── cat.png

processed/
├── dog.png
└── cat.png

CLI options

  • --api-key or REMOVE_BG_API_KEY environment variable (required).

  • --output-directory (optional) - The output directory for processed images.

  • --reprocess-existing - Images which have already been processed are skipped by default to save credits. Specify this flag to force reprocessing.

  • --confirm-batch-over (default 50) - Prompt for confirmation before processing batches over this size. Specify -1 to disable this safeguard.

Image processing options

Please see the API documentation for further details.

  • --size (default auto)
  • --type
  • --channels
  • --bg-color
  • --format (default: png)

Development

Prerequisites:

Getting started:

git clone git@github.com:remove-bg/go.git $GOPATH/github.com/remove-bg/go
cd $GOPATH/github.com/remove-bg/go
bin/setup
bin/test

To build & try out locally:

go build -o removebg main.go
./removebg --help
You can’t perform that action at this time.