Skip to content

Commit ebb2728

Browse files
committed
RemBG CLi V1.0.0
0 parents  commit ebb2728

File tree

8 files changed

+3176
-0
lines changed

8 files changed

+3176
-0
lines changed

.gitignore

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Dependencies
2+
node_modules/
3+
npm-debug.log*
4+
yarn-debug.log*
5+
yarn-error.log*
6+
7+
# Environment variables
8+
.env
9+
.env.local
10+
.env.development.local
11+
.env.test.local
12+
.env.production.local
13+
14+
# Output directories
15+
output/
16+
processed/
17+
dist/
18+
build/
19+
20+
# Logs
21+
logs
22+
*.log
23+
24+
# Runtime data
25+
pids
26+
*.pid
27+
*.seed
28+
*.pid.lock
29+
30+
# Coverage directory used by tools like istanbul
31+
coverage/
32+
33+
# nyc test coverage
34+
.nyc_output
35+
36+
# Dependency directories
37+
jspm_packages/
38+
39+
# Optional npm cache directory
40+
.npm
41+
42+
# Optional REPL history
43+
.node_repl_history
44+
45+
# Output of 'npm pack'
46+
*.tgz
47+
48+
# Yarn Integrity file
49+
.yarn-integrity
50+
51+
# dotenv environment variables file
52+
.env
53+
54+
# parcel-bundler cache (https://parceljs.org/)
55+
.cache
56+
.parcel-cache
57+
58+
# next.js build output
59+
.next
60+
61+
# nuxt.js build output
62+
.nuxt
63+
64+
# vuepress build output
65+
.vuepress/dist
66+
67+
# Serverless directories
68+
.serverless
69+
70+
# FuseBox cache
71+
.fusebox/
72+
73+
# DynamoDB Local files
74+
.dynamodb/
75+
76+
# TernJS port file
77+
.tern-port
78+
79+
# Stores VSCode versions used for testing VSCode extensions
80+
.vscode-test
81+
82+
# Built executables
83+
*.exe
84+
rembg-cli-win.exe
85+
rembg-cli-mac
86+
rembg-cli-linux
87+
88+
# OS generated files
89+
.DS_Store
90+
.DS_Store?
91+
._*
92+
.Spotlight-V100
93+
.Trashes
94+
ehthumbs.db
95+
Thumbs.db
96+
97+
# IDE files
98+
.vscode/
99+
.idea/
100+
*.swp
101+
*.swo
102+
*~
103+
104+
# Temporary files
105+
tmp/
106+
temp/
107+
108+
109+
#binaries
110+
*.exe

README.md

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
# RemBG CLI
2+
3+
A cross-platform command-line interface for batch background removal using the [rembg.js](https://github.com/Remove-Background-ai/rembg.js) library.
4+
5+
## Features
6+
7+
- 🚀 **Batch Processing**: Process single images or entire directories
8+
- 🌍 **Cross-Platform**: Works on Windows, macOS, and Linux
9+
- 🎨 **Multiple Formats**: Supports JPG, JPEG, PNG, and WEBP
10+
- 📊 **Progress Tracking**: Real-time progress indicators and detailed logging
11+
-**Fast Processing**: Optimized for speed and reliability
12+
- 🔧 **Flexible Configuration**: Environment variables and CLI options
13+
14+
## Installation
15+
16+
### Prerequisites
17+
18+
- Node.js v18.17.0 or higher
19+
- A valid API key from [RemBG.com](https://www.rembg.com/en)
20+
21+
### Setup
22+
23+
1. Use the release binaries or Clone this repository
24+
2. Install dependencies:
25+
```bash
26+
npm install
27+
```
28+
3. Set up your API key:
29+
```bash
30+
# Copy the example environment file
31+
cp env.example .env
32+
33+
# Edit .env and add your API key
34+
X_API_KEY=your_actual_api_key_here
35+
```
36+
37+
## Usage
38+
39+
### Basic Usage
40+
41+
```bash
42+
# Process a single image
43+
rembg-cli -i image.jpg -o ./output
44+
45+
# Process all images in a directory
46+
rembg-cli -i ./images -o ./output
47+
48+
# Specify output format
49+
rembg-cli -i ./images -o ./output -f png
50+
```
51+
52+
### Command Options
53+
54+
| Option | Short | Description | Default |
55+
|--------|-------|-------------|---------|
56+
| `--input` | `-i` | Input file or directory | Required |
57+
| `--output` | `-o` | Output directory | `./output` |
58+
| `--format` | `-f` | Output format (png, webp) | `webp` |
59+
| `--verbose` | `-v` | Enable verbose logging | `false` |
60+
| `--api-key` | | Override API key from environment | From env |
61+
| `--version` | | Show version number | |
62+
| `--help` | | Show help information | |
63+
64+
### Examples
65+
66+
```bash
67+
# Process a single PNG image
68+
rembg-cli -i photo.png -o ./processed
69+
70+
# Process all images in a folder with verbose output
71+
rembg-cli -i ./photos -o ./processed -v
72+
73+
# Process images and save as JPG
74+
rembg-cli -i ./photos -o ./processed -f jpg
75+
76+
# Use a different API key for this session
77+
rembg-cli -i ./photos -o ./processed --api-key your_key_here
78+
```
79+
80+
## Environment Variables
81+
82+
Create a `.env` file in the project root:
83+
84+
```env
85+
X_API_KEY=your_api_key_here
86+
DEFAULT_OUTPUT_FORMAT=webp
87+
DEFAULT_OUTPUT_DIR=./output
88+
```
89+
90+
## Building Executables
91+
92+
Build cross-platform executables using pkg:
93+
94+
```bash
95+
# Build for Windows
96+
npm run build:win
97+
98+
# Build for macOS
99+
npm run build:mac
100+
101+
# Build for Linux
102+
npm run build:linux
103+
104+
# Build for all platforms
105+
npm run build:all
106+
```
107+
108+
The built executables will be in the project root:
109+
- `rembg-cli-win.exe` (Windows)
110+
- `rembg-cli-mac` (macOS)
111+
- `rembg-cli-linux` (Linux)
112+
113+
## Supported Formats
114+
115+
### Input Formats
116+
- JPG/JPEG
117+
- PNG
118+
- WEBP
119+
120+
### Output Formats
121+
- WEBP (default)
122+
- PNG
123+
124+
## Error Handling
125+
126+
The CLI provides comprehensive error handling:
127+
128+
-**Validation**: Checks for required parameters and file existence
129+
- 🔍 **API Errors**: Handles API failures gracefully
130+
- 📁 **File System**: Manages directory creation and file operations
131+
- 🚨 **User Feedback**: Clear error messages and suggestions
132+
133+
## Performance Tips
134+
135+
1. **Batch Processing**: Process multiple images in a single command for better efficiency
136+
2. **Output Format**: Use PNG for best quality, WEBP for smaller file sizes and perfect for most users
137+
3. **API Limits**: The tool processes images sequentially to respect API rate limits
138+
4. **Storage**: Ensure sufficient disk space for output files
139+
140+
## Troubleshooting
141+
142+
### Common Issues
143+
144+
**"X_API_KEY is not set"**
145+
- Set your API key in the `.env` file or use the `--api-key` option
146+
147+
**"Input path does not exist"**
148+
- Check that the file or directory path is correct
149+
- Use absolute paths if relative paths don't work
150+
151+
**"No supported image files found"**
152+
- Ensure your files have supported extensions (.jpg, .jpeg, .png, .webp)
153+
- Check that the files are not corrupted
154+
155+
**"Failed to process image"**
156+
- Verify your API key is valid and has sufficient credits
157+
- Check your internet connection
158+
- Try processing the image individually to isolate the issue
159+
160+
### Getting Help
161+
162+
- Use `rembg-cli --help` for command options
163+
- Use `rembg-cli --version` to check the version
164+
- Enable verbose mode with `-v` for detailed logging
165+
166+
## License
167+
168+
MIT License - see LICENSE file for details.
169+
170+
## Contributing
171+
172+
Contributions are welcome! Please feel free to submit issues and pull requests.
173+
174+
## Support
175+
176+
For API-related issues, visit [RemBG Support page](https://www.rembg.com/en/contact).

env.example

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# RemBG API Configuration
2+
# Get your API key from: https://remove-background-ai.com/
3+
X_API_KEY=your_api_key_here
4+
5+
# Optional: Set default output format (png, jpg, webp)
6+
# DEFAULT_OUTPUT_FORMAT=png
7+
8+
# Optional: Set default output directory
9+
# DEFAULT_OUTPUT_DIR=./output

0 commit comments

Comments
 (0)