πΌοΈ Automatically remove the background from your images with Claude and RMBG
on August 24, 2025
Removing an image's background is a common task in design, e-commerce, and content creation. Many tools exist, some paid, others free... but when you want to automate the process, it can quickly become complicated.
In this article, I show you how to use Claude Code to assist you in installing and configuring RMBG (Remove Background), an open-source tool that automatically removes image backgrounds.
π The full source code is available here: π GitHub β matyo91/remove-background
π The various existing solutions
Before getting into the heart of the matter, here's a quick overview of the available solutions:
- Remove.bg: simple, effective, but paid (credit system + API).
- Adobe Photoshop: powerful, but requires a subscription.
- Canva: offers a Background Remover, but reserved for the Pro version.
- GIMP: free and open-source, but removal remains manual (selection by color, tolerance, etc.).
- RMBG: open-source, free, works from the command line or via a Python script β ideal for automation.
βοΈ Install Claude Code and start a project
Claude Code (by Anthropic) is a tool that assists developers directly in their terminal. It allows you to:
- install dependencies,
- fix common errors,
- speed up the setup of complex environments.
Quick Installation
npm install -g @anthropic-ai/claude-code
Then, run:
claude
Claude will guide you step by step (authentication, configuration, etc.).
π Complete documentation: Claude Code β Anthropic
πΌοΈ First attempt with GIMP
With GIMP, it's possible to remove the background using the Select by Color Tool (Shift+O). But the process is entirely manual: click on the background, adjust the tolerance, start again...
π Result: Useful for some images, but not suitable for automation.
π§ Installing and using RMBG
RMBG is easily installed with Python:
pip3 install rembg
If any dependencies are missing (Onnx Runtime, aiohttp, etc.), Claude Code automatically detects them and offers to fix them with one click.
Then, the basic command is simple:
rembg i input.png output.png
π This command takes input.png
and generates output.png
without the background.
π Automate with a Python script
To go further, we can automate the processing of an entire folder of images.
Example Python script (present in the GitHub repo):
from rembg import remove
import bone
input_folder = "images"
output_folder = "imagesRemoveBackground"
os.makedirs(output_folder, exist_ok=True)
for file_name in os.listdir(input_folder):
if file_name.lower().endswith((".png", ".jpg", ".jpeg")):
input_path = os.path.join(input_folder, file_name)
output_path = os.path.join(output_folder, file_name)
with open(input_path, "rb") as inp, open(output_path, "wb") as out:
out.write(remove(inp.read()))
π Place your images in images/
, run the script, and all your photos will be generated without background in imagesRemoveBackground/
.
π Documentation and available templates
RMBG can be used in several ways:
- As a Python library,
- As an HTTP Server,
- Via Docker.
It also supports different templates (UΒ²Net, etc.), adapted to the type of image to be processed (e-commerce products, portraits, various objects).
π Official documentation: RMBG GitHub
β Conclusion
In this article, we have seen several solutions for removing the background from an image.
- Paid tools (Remove.bg, Photoshop, Canva) work well but are expensive.
- GIMP remains a good manual option, but has limitations.
- The Claude Code + RMBG combination is the most effective way to automate the process easily and for free.
π Try it now by cloning the repo: π matyo91/remove-background
π If you liked this tutorial, please share it, leave a comment, and try RMBG for your own projects!
π I offer free 30-minute coaching sessions to help creators like you automate their processes and save time β±οΈ
π Book your free session here: https://www.bonzai.pro/matyo91/lp/4471/je-taide-a-automatiser-tes-process
Thank you for reading! Let's create smart, fast, and automated workflows together π»β‘