Skip to content

execute008/clitools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CLI Tools

A collection of command-line utilities for various development tasks, with a focus on web optimization.

Features

Image Optimization

The image optimization tool helps prepare images for web use by:

  1. Cropping transparent areas - Removes all transparent padding/offset to reduce file size
  2. WebP conversion - Converts images to WebP format for better compression
  3. Quality control - Adjustable quality settings for optimal size/quality balance

Installation

  1. Clone the repository:
git clone <repository-url>
cd clitools
  1. Install dependencies:
go mod download
  1. Build the CLI tool:
go build -o clitools .

Usage

Image Optimization

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)

Examples

# 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

Web Optimization Benefits

This tool is specifically designed for web optimization:

  1. Smaller file sizes - WebP format provides 25-35% better compression than JPEG/PNG
  2. Faster loading - Removing transparent padding reduces unnecessary data
  3. Better performance - Optimized images improve page load times
  4. Maintained quality - Adjustable quality settings preserve visual fidelity

Development

Project Structure

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

Adding New Tools

To add a new tool to the CLI:

  1. Create a new command file in cmd/
  2. Add the command to cmd/root.go
  3. Implement the logic in internal/

Building for Distribution

# 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 .

Dependencies

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published