CLI tool that fills transparent image backgrounds with a solid color.
Features
·
Installation
·
Usage
·
Examples
backdrop takes an image with a transparent background — a local file, URL, or emoji — and fills it with a solid color.
I built this to generate consistent project avatars for GitLab, but it works anywhere you need a quick, polished image with a colored background — favicons, social cards, README badges, etc.
- Multiple input sources — local files, HTTP(S) URLs, or emoji (e.g.
🏠) - Flexible color input — hex (
#FF5733) or RGB (255,87,51) - Square mode — force output to a perfect square
- Padding — add breathing room in pixels (
--padding 20) or as a percentage of the image (--padding 10%)
brew install josepmedialdea/tap/backdropgit clone https://github.com/josepmedialdea/backdrop.git
cd backdrop
make build
# binary is at ./bin/backdropgo install github.com/josepmedialdea/backdrop/cmd/backdrop@latestbackdrop <image|emoji> [flags]
| Flag | Short | Default | Description |
|---|---|---|---|
--color |
-c |
#000000 |
Background color as hex (#rrggbb) or R,G,B |
--output |
-o |
auto | Output file path (default: <input>_bg.<ext>) |
--force |
false |
Overwrite output file if it already exists | |
--square |
false |
Make output image a perfect square | |
--padding |
0 |
Padding on all sides: pixels (e.g. 20) or percentage (e.g. 10%) |
# Fill a local PNG with a blue background
backdrop logo.png -c "#3498db"
# Fetch an image from a URL and apply a red background
backdrop https://example.com/icon.png -c 255,0,0
# Render an emoji with a dark background
backdrop 🦞 -c "#1a1a2e"
# Square output with 10% padding
backdrop logo.png -c "#2ecc71" --square --padding 10%
# Explicit output path, overwrite if exists
backdrop logo.png -c "#000000" -o result.png --force