A fast image converter built in Go. Webd processes all images in a given directory, converting only targeted formats to desired formats. This tool is helpful for bulk conversions and can be potentially automated using scripts. Support for more formats coming soon!
- Fast conversions powered by concurrency
- PNG ⇔ WebP
- JPEG ⇔ PNG
- JPEG ⇔ WEBP
- Optional cleanup - Delete/replace original files after conversion
- Verbose logging - Track conversion timing and operations
- Targeted conversion - Only processes specified file types, leaving others untouched (no need to worry about having other file types mixed in)
- Go version 1.22 or higher
go install github.com/v4n1lla-1ce/webd/cmd/webd@latest# you MUST specify a conversion flag i.e. -webp2png
webd <flags> <directory># Help Menu (both works)
webd -h
webd
# Convert all WebP files to PNG in current directory
webd --webp2png .
# Convert all WebP files to PNG in a specific directory whilst deleting all original files
# Setting --verbose will turn on logs
webd --webp2png -d --verbose /path/to/images
# Convert all PNG files to WebP in parent directory
webd --png2webp ../If you get a "command not found" error after installation, you need to add Go's bin directory to your PATH:
Add this line to your ~/.bashrc, ~/.zshrc, or equivalent:
export PATH=$PATH:$(go env GOPATH)/binThen restart your terminal or run:
source ~/.bashrc # or source ~/.zshrc- Open System Properties → Advanced → Environment Variables
- Under "User variables", find "Path"
- Click "Edit" and add:
%USERPROFILE%\go\bin - Click "OK" to save
- Restart your terminal
| Options | Description |
|---|---|
-h |
Display help menu |
-d |
Delete original files after conversion |
-v |
Display version information. |
--verbose |
Logs the files converted/deleted depending on options selected |
--webp2png |
Converts WEBP files to PNG in the directory specified |
--webp2jpg |
Converts WEBP files to JPEG in the directory specified |
--png2webp |
Converts PNG files to WEBP in the directory specified |
--png2jpg |
Converts PNG files to JPEG in the directory specified |
--jpg2png |
Converts JPEG files to PNG in the directory specified |
--jpg2webp |
Converts JPEG files to WEBP in the directory specified |
This project demonstrates the pipeline concurrency pattern in Go. Here's how WebD processes multiple images efficiently using concurrent stages.
Converting multiple WebP images to PNG format presents several challenges:
- CPU-intensive image decoding/encoding
- I/O operations for reading/writing files
- Processing multiple files efficiently
Traditional sequential processing would be slow, especially for large directories.
WebD implements a concurrent pipeline where each processing stage runs independently:
func NewPipeline[I any, O any](input <-chan I, process func(I) O) <-chan O {
out := make(chan O)
go func() {
defer close(out)
for in := range input {
out <- process(in)
}
}()
return out
}Load Files → Decode WebP → Encode PNG → Save to Disk
↓ ↓ ↓ ↓
[webp imgs] → [images] → [png bytes] → [saved files]
Data flows through the pipeline using a custom structure:
type PipelineData struct {
Value any // Current processing data
SourcePath string // Original file path
Directory string // Working directory
BaseName string // Original filename
}The pipeline is constructed in stages:
// This is a simplified version
files := LoadPipeline(directory) // Find WebP files
decoded := NewPipeline(files, DecodeWebp) // Decode WebP
encoded := NewPipeline(decoded, EncodePng) // Encode PNG
saved := NewPipeline(encoded, SaveToDisk) // Save files-
Concurrent Processing
- Multiple images processed simultaneously
- Efficient CPU utilization
- Reduced total processing time
-
Memory Efficiency
- Works like a conveyor belt, processes one image at a time
- Only loads a few images at once, not your entire folder
- Automatically slows down if your computer gets busy
-
Maintainable Code
- Clear separation of concerns
- Easy to add new processing stages
This project is licensed under the MIT License - see the LICENSE file for details.

