A collection of command-line utilities for various development tasks, with a focus on web optimization.
The image optimization tool helps prepare images for web use by:
- Cropping transparent areas - Removes all transparent padding/offset to reduce file size
- WebP conversion - Converts images to WebP format for better compression
- Quality control - Adjustable quality settings for optimal size/quality balance
- Clone the repository:
git clone <repository-url>
cd clitools
- Install dependencies:
go mod download
- Build the CLI tool:
go build -o clitools .
Optimize an image by cropping transparent areas and converting to WebP:
# Basic usage
./clitools image optimize input.png output.webp
# With custom quality (0-100, default: 80)
./clitools image optimize input.jpg output.webp --quality 90
# Short flag version
./clitools image optimize input.png output.webp -q 75
Supported input formats:
- PNG
- JPEG/JPG
- SVG (vector graphics - rasterized to bitmap)
- Other formats supported by Go's image package
Output format:
- WebP (always, regardless of input format)
# Optimize a PNG with transparency
./clitools image optimize logo.png logo-optimized.webp
# Optimize a JPEG photo
./clitools image optimize photo.jpg photo-optimized.webp --quality 85
# Convert SVG to optimized WebP (rasterized)
./clitools image optimize icon.svg icon-optimized.webp --quality 90
# The tool will automatically add .webp extension if not provided
./clitools image optimize input.png output
# Output will be saved as: output.webp
This tool is specifically designed for web optimization:
- Smaller file sizes - WebP format provides 25-35% better compression than JPEG/PNG
- Faster loading - Removing transparent padding reduces unnecessary data
- Better performance - Optimized images improve page load times
- Maintained quality - Adjustable quality settings preserve visual fidelity
clitools/
├── main.go # Entry point
├── cmd/ # CLI commands
│ ├── root.go # Root command
│ └── image.go # Image manipulation commands
├── internal/
│ └── image/
│ └── processor.go # Image processing logic
└── go.mod # Go module file
To add a new tool to the CLI:
- Create a new command file in
cmd/
- Add the command to
cmd/root.go
- Implement the logic in
internal/
# Build for current platform
go build -o clitools .
# Build for multiple platforms
GOOS=linux GOARCH=amd64 go build -o clitools-linux-amd64 .
GOOS=windows GOARCH=amd64 go build -o clitools-windows-amd64.exe .
GOOS=darwin GOARCH=amd64 go build -o clitools-darwin-amd64 .
This project is licensed under the MIT License - see the LICENSE file for details.