Image Editing

Jan 23, 2024

Removing & Replacing the Background of Multiple Images Using’s CLI Tool

Are you eager to integrate AI and automation into your business, but feel limited by the lack of in-depth technical expertise or a specialized IT team? Look no further! offers a comprehensive, easy-to-follow guide on setting up an API command line-enabled folder right on your desktop.

Experience the convenience of drag-and-drop functionality to remove the backgrounds of multiple images at once. Embrace this swift and straightforward approach to automation and transform your desktop into a dynamic design studio.

What is a Command Line Interface (CLI)?

A Command Line Interface is a tool that runs in the Terminal that is included in every operating system and allows you to run programs and tasks using simple text commands rather than clicking with the mouse.

The CLI tool gives you the most power with optimal performance and freedom.  While the entire documentation and source code for the CLI tool can be found on's website, we've taken the time to give you an easy, step-by-step video tutorial to get you started. Let's go!

If you're looking to dive deeper and see the steps laid out in writing, keep on reading.

How to use the CLI tool

If you’re a Mac OS user and have Homebrew installed on your system, you can install it with a simple command:

brew install remove-bg/homebrew-tap/removebg

Or you can download the latest stable release for your platform of choice.

Extract the archive file to your destination folder of choice. If you would like to be able to use the CLI tool from anywhere on your computer, make sure to add the path to your > PATH environment variable.


Open the Environment Variables dialog by clicking on the > Start Menu and typing > environment variables and hitting > ENTER.

Click on the button > Environment Variables

Find the variable named > Path, select it, and hit the button > Edit. The > Path environment variables exist both for your user account and for the entire system. If you would like every user to be able to use the CLI tool, then choose the Path system variable.

Click the button > New to add a new entry to the Path environment variable.

A new input field will appear. Type in the folder location you extracted removebg.exe to, then click > OK.


In Finder, navigate to your home folder: /Users/<username>.  If you’re using macOS Catalina (10.15) or later, create or open the file .zshrcIf you’re using Mojave (10.14) or earlier, the filename is .bashrc Add the following line and save the file:

export PATH="${PATH}:/path/to/removebg"


Depending on the shell you’re using, create/edit the file ~/.bashrc or ~/.zshrc and add the following line and save the file:

export PATH="${PATH}:/path/to/removebg"

Retrieve your API key

You’ll need your API key every time you use the CLI tool. Log in to your dashboard, and click the > API Keys tab.

To create a new API key for use with the CLI tool, click on the > New API Key button.

Give the key a meaningful name, like > CLI Tool, and click the > Create API Key button.

Once the key is created, click the > Copy button to copy it to the clipboard.

NOTE: you can save the API key as an environment variable, so you don't have to enter the key every time you use the CLI tool.


Open the Environment Variables dialog by clicking on the Start Menu, typing environment variables, and hitting ENTER.

Click on the button > Environment Variables.

Click on the button > New. You can choose to have the environment variable applicable only for your user, or for everyone who uses the system.

Enter REMOVE_BG_API_KEY as the variable name, and enter your API key as the value.  Then click the > OK button.


Simply add the following line to either ~/.bashrc or ~/.zshrc file:

export REMOVE_BG_API_KEY=”your_key_here”

Execute your first command

That's all the setup we had to do, so now we can get right to it!


Open the Command Prompt by clicking on the Start Menu, typing cmd, and hitting ENTER.


Open the terminal by clicking the Launchpad icon, then searching for > terminal.


Open the terminal in accordance with your Linux distribution.

Command anatomy

To execute a command using the CLI tool, you must follow the basic structure:

removebg [options] file...

If you didn’t update your PATH environment variable,  you need to give the full path of the executable:


C:\removebg\removebg [options] file...


/path/to/removebg/removebg [options] file...

For the [options] part, each option follows the same structure:

--option value

So, for example, if you didn't add REMOVE_BG_API_KEY to your environment variables, you must always enter the API key as an option:

removebg --api-key your_api_key_here

The file part of the command is where you tell the CLI tool which files you'd like to process. Let's have a look at some useful examples to get you started.

Processing a single image

To remove the background of a single image:


removebg C:\path\to\image.png


removebg /path/to/image.png

This will remove the background of the image and save it in the same directory as image-removebg.png.

Processing a folder of images

If you have multiple images in a folder and want to remove the background, use the command:


removebg C:\path\to\images\*.{jpg,jpeg,png}


removebg /path/to/images/*.{jpg,jpeg,png}

This will remove the background of all the .jpg, .jpeg, and .png files in the specified directory and save them in the same directory as image-removebg.png.

Saving to a different directory

If you want to save the files to a different directory, you can simply use the --output-directory option:


removebg --output-directory C:\path\to\images\output C:\path\to\images\*.{jpg,jpeg,png}


removebg --output-directory /path/to/images/output /path/to/images/*.{jpg,jpeg,png}

If the specified output directory doesn’t exist, it will be created for you automatically.

Giving the AI a hint as to what’s in the foreground

You can also tell the AI what kind of object it should be looking for as the foreground object with the --type option.  You can enter any text, but try to use something generic and only one word, like “person”, “car”, or “toothbrush”:


removebg --type camera C:\path\to\images\*.{jpg,jpeg,png}


removebg --type camera /path/to/images/*.{jpg,jpeg,png}

Setting the output format

By default, the output file will be in PNG format, which is the only format supporting transparency.  However, you can override this and save it as a JPG if so desired with the --format option:


removebg --format jpg C:\path\to\images\*.{jpg,jpeg,png}


removebg --format jpg /path/to/images/*.{jpg,jpeg,png}

Setting the output size

By default the output file has the same size as the input file.  If you want to resize the images, you can use the --size option, which has the following values:

  • auto: highest available resolution based on the number of credits and original file size (this is the default)

  • full: original resolution up to 25 megapixels for JPG and 10 megapixels for PNG

  • preview: 0.25 megapixels


removebg --size preview C:\path\to\images\output C:\path\to\images\*.{jpg,jpeg,png}


removebg --size preview /path/to/images/output /path/to/images/*.{jpg,jpeg,png}

Adding a background color

If you want to add a background color to all images instead of letting it just be transparent, you can simply use the --bg-color option with a RGB hex color code (without the #) or just the color name (e.g. “blue”):


removebg --bg-color 0031BA C:\path\to\images\*.{jpg,jpeg,png}


removebg --bg-color 0031BA /path/to/images/*.{jpg,jpeg,png}

Adding a background image

If you want to add a background image to all images instead of a solid color, you can simply use the --bg-image-file option:


removebg --bg-image-file C:\path\to\bg-image.jpg C:\path\to\images\*.{jpg,jpeg,png}


removebg --bg-image-file /path/to/bg-image.jpg /path/to/images/*.{jpg,jpeg,png} CLI tool: leverage AI & automation

In this guide, we’ve seen how we can remove the backgrounds of multiple files at once, with multiple options, all with just a single command.

The Command Line Interface tool empowers you to not only eliminate backgrounds but also to substitute them with a chosen background color or a different image. Additionally, it allows you to modify the output format and adjust the size to suit your needs.

It is a super helpful way to process large batches of files in an automated or semi-automated way.  If you get stuck or have any questions not covered in this guide, check out our help center. If you are interested in knowing more about's high-volume solutions, contact us directly. Happy background removing!



コメントはまだありません。 - Remove Background from Image 100% Free! | Product Hunt
  • 詳しいこと

  • Magic Brush
  • 個人
  • 撮影者
  • マーケティング
  • 開発者
  • E コマース
  • メディア
  • 自動車ディーラー
  • 企業
  • Success stories
  • ツール & API

  • API ドキュメンテーション
  • 統合、ツール、アプリ
  • Photoshop拡張
  • Windows / Mac / Linux
  • Androidアプリ
  • デザインテンプレート
  • サポート

  • ヘルプ & よくある質問
  • お問い合わせ
  • 返戻
  • プラットフォームの状態
  • 当社

  • ブログ
  • アフィリエイトプログラム
  • 自動でデザインを作成
  • ビデオの背景削除
  • キャリア
  • 当社について
  • プレス

©, a Canva Austria GmbH brand

  • 利用規約
  • 一般取引条件
  • プライバシーポリシー
  • Cookieポリシー
  • インプリント


当社の向上に支援しませんか? (任意で)

  • 画像の使用許可を与えると、remove.bgの向上に役立つことができます。
  • 人工知能に教える。
  • 今後は類似画像のより精度いい仕上がることができます。