Coder Social home page Coder Social logo

go-1's Introduction

remove.bg CLI

CircleCI

Installation

Download

You can download latest stable release (Windows, Mac, and Linux supported)

Homebrew

brew install remove-bg/homebrew-tap/removebg

deb / rpm

Download the .deb or .rpm from the releases page and install with dpkg -i and rpm -i.

For the latest deb package supporting x86-64 you can also run:

curl -LO $(curl https://api.github.com/repos/remove-bg/go/releases/latest | grep -o "https://github.com/remove-bg/go/releases/download/.*linux_amd64.deb")
sudo dpkg -i removebg*.deb

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)
  • --extra-api-options for forwarding any unlisted/new options to the API
    • Formatted as a URI encoded string (= between key/value, delimited with &)
    • e.g. --extra-api-options 'crop=true&add_shadow=true'

Examples

# Producing a JPG with a grey background at the path: processed/subject.jpg
removebg subject.jpg --format jpg --bg-color 7a7a7a --output-directory processed

# Producing a large transparent PNG image up to 25 megapixels
removebg large.jpg --size full --format png

# Processing a car image with additional API options
removebg car.jpg --type car --extra-api-options 'add_shadow=true&semitransparency=true'

Development

Prerequisites:

Getting started:

git clone [email protected]: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

Releasing a new version

GITHUB_TOKEN=xyz bin/release vX.Y.Z

go-1's People

Contributors

odlp avatar groe avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.