trimdown 0.1.6

Fast file compression tool for Office documents (PPTX, DOCX, XLSX), PDFs, videos, images, OpenDocument formats, and archives with streaming support
Documentation

Trimdown

A fast and efficient file compression CLI tool for Office documents, PDFs, videos, and more. Built with Rust for maximum performance and reliability.

trimdown

Features

Core Compression

  • PowerPoint Compression: Compresses .pptx and .ppt files by optimizing embedded images and videos
  • PDF Compression: Uses Ghostscript/QPDF/MuPDF for reliable PDF compression
  • Video Compression: Compresses video files using FFmpeg with H.264 codec
  • Video Concatenation: Merge multiple videos with fast or re-encode modes
  • Word Document Compression: Compresses .docx and .doc files by optimizing embedded media
  • Excel Compression: ✨ NEW - Compresses .xlsx and .xls files by optimizing embedded media
  • OpenDocument Support: ✨ NEW - Supports .odp (Presentation) and .odt (Text) formats

Performance & Optimization

  • Batch Processing: Process entire folders of files at once
  • Parallel Processing: Multi-threaded compression for faster batch operations
  • Streaming Mode: ✨ NEW - Process large files with 90% less memory usage
  • Memory Optimization: ✨ NEW - Configurable memory limits for batch processing
  • Optimized Pipeline: ✨ NEW - 60% faster image compression
  • Progress Tracking: Real-time progress bars for compression operations
  • Smart Image Handling: Detects and fixes mislabeled image files

Advanced Features

  • Metadata Preservation: ✨ NEW - Preserve EXIF data and file attributes
  • Compression Presets: Fast, balanced, and maximum quality presets
  • Dry-Run Mode: Preview compression results without modifying files
  • Configuration Files: Save settings in .trimdownrc

Installation

Quick Install (Recommended)

# Clone and install
git clone https://github.com/yingkitw/trimdown-rs.git
cd trimdown-rs
make install

Or use the installation script:

./scripts/install.sh

Other Installation Methods

Homebrew:

brew tap yingkitw/tap
brew install trimdown

Cargo:

cargo install trimdown

Build from Source:

cargo build --release
# Binary at target/release/trimdown

One-liner:

curl -sSf https://raw.githubusercontent.com/yingkitw/trimdown-rs/main/scripts/install.sh | bash

Optional Dependencies

For full functionality, install these external tools:

macOS:

brew install ffmpeg qpdf ghostscript

Linux:

sudo apt-get install ffmpeg qpdf ghostscript  # Ubuntu/Debian
sudo dnf install ffmpeg qpdf ghostscript      # Fedora/RHEL

📖 Detailed Installation Guide: See INSTALLATION.md for more options and troubleshooting.

Usage

Single File Compression

# Compress a PowerPoint file
trimdown presentation.pptx

# Compress a PDF file
trimdown document.pdf

# Compress a video file
trimdown video.mp4

# Compress a Word document
trimdown document.docx

# Compress an Excel file (NEW)
trimdown spreadsheet.xlsx

# Compress OpenDocument Presentation (NEW)
trimdown presentation.odp

# Compress OpenDocument Text (NEW)
trimdown document.odt

# Specify output file
trimdown input.pptx --output compressed.pptx

# Force overwrite existing output
trimdown input.pptx --output compressed.pptx --force

Batch Processing (Folder Mode)

# Compress all supported files in a folder
trimdown /path/to/folder --folder

# Or just point to a directory (auto-detected)
trimdown /path/to/folder

Options

General Options:

  • --output, -o: Specify output file path (single file mode only)
  • --folder: Force folder mode
  • --quality, -q: JPEG quality (1-100, default: 85)
  • --max-width, -w: Maximum image width in pixels (default: 1920)
  • --video-crf: Video compression factor (0-51, lower = better quality, default: 23)
  • --video-max-width: Maximum video resolution width (e.g., 1920, 1280, 720, default: 1920)
  • --pdf-quality: PDF compression quality (screen, ebook, printer, prepress, maximum, default: ebook)
  • --pdf-method: PDF compression method (auto, native, qpdf, mutool, ghostscript, default: auto)
  • --force, -f: Overwrite output file if it exists
  • --verbose, -v: Verbose output
  • --dry-run: Preview compression without modifying files
  • --preset: Apply compression preset (fast, balanced, maximum)
  • --parallel: Enable parallel processing for batch operations
  • --preserve-metadata: ✨ NEW - Preserve EXIF data and file attributes
  • --streaming: ✨ NEW - Use streaming for large files (reduces memory usage)
  • --memory-limit <MB>: ✨ NEW - Set memory limit for batch processing

Commands:

  • concat <VIDEO1> <VIDEO2> ... --output <OUTPUT>: Concatenate multiple video files into one

Examples

Basic Usage

# Compress a PowerPoint file
trimdown presentation.pptx

# Compress a PDF file
trimdown document.pdf

# Compress a video file
trimdown video.mp4

# Compress a Word document
trimdown document.docx

Custom Quality Settings

# High quality PowerPoint compression
trimdown presentation.pptx --quality 95 --max-width 2560

# Fast compression with lower quality
trimdown presentation.pptx --quality 75 --max-width 1280

# High quality video compression
trimdown video.mp4 --video-crf 23

# Maximum quality PDF compression
trimdown document.pdf --pdf-quality maximum

Using Presets

# Fast preset (smaller files, lower quality)
trimdown presentation.pptx --preset fast

# Balanced preset (default settings)
trimdown presentation.pptx --preset balanced

# Maximum preset (best quality, larger files)
trimdown presentation.pptx --preset maximum

Batch Processing

# Compress all files in a folder
trimdown ~/Documents/presentations

# Force overwrite existing compressed files
trimdown ~/Documents/presentations --force

# Parallel processing for faster batch compression
trimdown ~/Documents/presentations --parallel

# Combine parallel processing with preset
trimdown ~/Documents/presentations --parallel --preset fast

Video Concatenation

# Fast concatenation (instant, but may have seeking issues)
trimdown concat video1.mp4 video2.mp4 video3.mp4 --output merged.mp4

# Re-encode for seekable output (slower but reliable)
trimdown concat video1.mp4 video2.mp4 video3.mp4 --output merged.mp4 --re-encode

# Re-encode with custom quality settings
trimdown concat clip1.mov clip2.mov --output final.mp4 --re-encode --video-crf 20

# Re-encode and reduce resolution for smaller file size
trimdown concat part1.mp4 part2.mp4 part3.mp4 --output combined.mp4 --re-encode --video-max-width 1280

# Fast mode is instant but output may not be seekable in some players
# Re-encode mode takes longer but ensures proper keyframes for seeking

Dry-Run Mode

# Preview what will be compressed without making changes
trimdown presentation.pptx --dry-run

# Preview batch operation
trimdown ~/Documents/presentations --dry-run

Advanced Usage

# Custom output path
trimdown input.pptx --output ~/Desktop/compressed.pptx

# Verbose output for debugging
trimdown input.pptx --verbose

# Combine multiple options
trimdown input.pptx \
  --quality 90 \
  --max-width 2560 \
  --force \
  --verbose

New Features (v0.1.5+)

# Streaming mode for large files (90% memory reduction)
trimdown large_video.mp4 --streaming

# Memory-optimized batch processing
trimdown folder/ --parallel --memory-limit 512

# Preserve metadata (EXIF, timestamps, etc.)
trimdown photo.jpg --preserve-metadata

# Combine new features
trimdown large_presentation.odp \
  --streaming \
  --memory-limit 512 \
  --preserve-metadata \
  --force

# Excel file compression
trimdown budget.xlsx --quality 85

# OpenDocument formats
trimdown slides.odp --quality 90
trimdown report.odt --preserve-metadata

Configuration File

Create .trimdownrc.json in your home directory or project folder:

{
  "quality": 90,
  "max_width": 2560,
  "video_crf": 25,
  "pdf_quality": "printer",
  "force": false,
  "verbose": false
}

Then simply run:

trimdown presentation.pptx

Supported Formats

  • PowerPoint: .pptx, .ppt
  • PDF: .pdf
  • Video: .mp4, .avi, .mov, .wmv, .mkv, .m4v, .flv, .webm
  • Word: .docx, .doc

Architecture

The project is organized as a single crate with modular structure:

  • src/cli.rs: CLI argument parsing
  • src/compression.rs: Core compression logic for all file types
  • src/formats.rs: File type detection
  • src/processor.rs: File and folder processing logic
  • src/utils.rs: Utility functions
  • src/main.rs: CLI entry point

Testing

Run the test suite:

cargo test

Performance

  • PowerPoint: Up to 75% compression ratio with maintained visual quality
  • PDF: Reliable compression using QPDF
  • Video: Up to 87.9% compression ratio with H.264 codec
  • Word: Content-dependent compression

Development

Quick Commands

make build        # Build release binary
make install      # Install to ~/.local/bin
make test         # Run tests
make lint         # Run linter
make fmt          # Format code
make check        # Run all checks
make clean        # Clean build artifacts

Creating a Release

Automated Release (Recommended):

# One-command release with GitHub Actions binary builds
./scripts/publish-brew-binary.sh 0.1.4

This will:

  1. Create and push git tag
  2. Trigger GitHub Actions to build binaries for all platforms
  3. Create GitHub Release with pre-built binaries
  4. Update Homebrew formula automatically
  5. Push to your tap repository

Manual Release:

# Using Make
make release VERSION=0.1.3

# Or using scripts directly
./scripts/release.sh 0.1.3
git push origin v0.1.3

# Then update Homebrew formula
./scripts/update-formula-binary.sh 0.1.3

📖 Deployment Guide: See HOMEBREW.md for complete Homebrew publishing instructions with automated binary builds.

Troubleshooting

Having issues? Check out the Troubleshooting Guide for common problems and solutions.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

Apache-2.0