Trimdown
A fast and efficient file compression CLI tool for PowerPoint, PDF, Video, and Word documents. Migrated from the compression capability of deck-agent.
Features
- PowerPoint Compression: Compresses
.pptxand.pptfiles by optimizing embedded images and videos - PDF Compression: Uses QPDF for reliable PDF compression
- Video Compression: Compresses video files using FFmpeg with H.264 codec
- Word Document Compression: Compresses
.docxand.docfiles by optimizing embedded media - Batch Processing: Process entire folders of files at once
- Progress Tracking: Real-time progress bars for compression operations
- Smart Image Handling: Detects and fixes mislabeled image files (e.g., JPEG files with PNG extensions)
Installation
Quick Install (Recommended)
# Clone and install
Or use the installation script:
Other Installation Methods
Homebrew:
Cargo:
Build from Source:
# Binary at target/release/trimdown
One-liner:
|
Optional Dependencies
For full functionality, install these external tools:
macOS:
Linux:
📖 Detailed Installation Guide: See INSTALLATION.md for more options and troubleshooting.
Usage
Single File Compression
# Compress a PowerPoint file
# Compress a PDF file
# Compress a video file
# Compress a Word document
# Specify output file
# Force overwrite existing output
Batch Processing (Folder Mode)
# Compress all supported files in a folder
# Or just point to a directory (auto-detected)
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: 28)--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
Examples
Basic Usage
# Compress a PowerPoint file
# Compress a PDF file
# Compress a video file
# Compress a Word document
Custom Quality Settings
# High quality PowerPoint compression
# Fast compression with lower quality
# High quality video compression
# Maximum quality PDF compression
Using Presets
# Fast preset (smaller files, lower quality)
# Balanced preset (default settings)
# Maximum preset (best quality, larger files)
Batch Processing
# Compress all files in a folder
# Force overwrite existing compressed files
# Parallel processing for faster batch compression
# Combine parallel processing with preset
Dry-Run Mode
# Preview what will be compressed without making changes
# Preview batch operation
Advanced Usage
# Custom output path
# Verbose output for debugging
# Combine multiple options
Configuration File
Create .trimdownrc.json in your home directory or project folder:
Then simply run:
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 parsingsrc/compression.rs: Core compression logic for all file typessrc/formats.rs: File type detectionsrc/processor.rs: File and folder processing logicsrc/utils.rs: Utility functionssrc/main.rs: CLI entry point
Testing
Run the test suite:
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
Creating a Release
# Using Make
# Or using scripts directly
📖 Deployment Guide: See DEPLOYMENT.md for release checklist and HOMEBREW.md for Homebrew publishing instructions.
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