|
1
|
--- |
|
2
|
name: remove-image-background |
|
3
|
description: Remove backgrounds from existing images, producing transparent PNG files. |
|
4
|
--- |
|
5
|
|
|
6
|
# Remove Image Background Skill |
|
7
|
|
|
8
|
Remove the background from an existing image file in the project, producing a transparent PNG. |
|
9
|
|
|
10
|
## Available Functions |
|
11
|
|
|
12
|
### removeImageBackground(imagePath, ...) |
|
13
|
|
|
14
|
Remove the background from an existing image file. |
|
15
|
|
|
16
|
**Parameters:** |
|
17
|
|
|
18
|
- `imagePath` (str, required): Path to the input image file |
|
19
|
- `outputPath` (str, optional): Path to save the result PNG. Defaults to replacing the extension with `_no_bg.png` |
|
20
|
|
|
21
|
**Returns:** Dict with `outputPath` key containing the path to the saved result |
|
22
|
|
|
23
|
**Example:** |
|
24
|
|
|
25
|
```javascript |
|
26
|
const result = await removeImageBackground({ |
|
27
|
imagePath: "attached_assets/photo.jpg", |
|
28
|
outputPath: "attached_assets/photo_no_bg.png" |
|
29
|
}); |
|
30
|
console.log(`Result saved to: ${result.outputPath}`); |
|
31
|
``` |
|
32
|
|
|
33
|
## When to Use |
|
34
|
|
|
35
|
- User has an existing image and wants its background removed |
|
36
|
- User uploads a photo and asks to make the background transparent |
|
37
|
- Creating transparent versions of logos, product photos, or portraits |
|
38
|
- Preparing images for compositing or overlay on other backgrounds |
|
39
|
|
|
40
|
## Best Practices |
|
41
|
|
|
42
|
1. **Output must be PNG**: The output file must have a `.png` extension since transparency requires PNG format |
|
43
|
2. **Use default output path when possible**: Omit `outputPath` to automatically save as `<original_name>_no_bg.png` |
|
44
|
3. **Supported input formats**: Works with common image formats (PNG, JPG, JPEG, WebP, etc.) |
|
45
|
|
|
46
|
## Output Location |
|
47
|
|
|
48
|
- Default output: Same directory as input, with `_no_bg.png` suffix |
|
49
|
- Custom output: Any path ending in `.png` |
|
50
|
|
|
51
|
## Limitations |
|
52
|
|
|
53
|
- Output format is always PNG (required for transparency) |
|
54
|
- Very complex backgrounds or low-contrast edges may not be perfectly removed |
|
55
|
- Works best with clear foreground subjects (people, objects, logos) |