Skip to content

Repository files navigation

Universal File Compressor - Advanced Multi-Format Compression Tool

A powerful, client-side file compression tool that reduces file sizes using advanced algorithms and multi-threaded processing. Supports PDF, images, documents, and archives with multiple compression methods - all processed securely in your browser.

πŸš€ Key Features

Advanced Compression

  • Multi-threaded Processing - Uses Web Workers for parallel compression of multiple files
  • Advanced Algorithms - Implements Brotli, gzip, and optimized image encoding
  • Smart Compression - Automatically selects the best compression method for each file type
  • Custom Target Size - Set specific target file sizes for precise compression control

Multi-Format Support

  • PDF Files - Advanced PDF compression with image optimization
  • Images - JPEG, PNG, WebP, BMP compression with quality control
  • Documents - Text, HTML, CSS, JavaScript, JSON, XML compression
  • Archives - ZIP file optimization (coming soon)

Compression Presets

  • Quality Mode - High quality, moderate compression (85% quality, 90% scale)
  • Balanced Mode - Best balance of size and quality (60% quality, 70% scale)
  • Maximum Mode - Maximum compression, lower quality (30% quality, 50% scale)
  • Custom Mode - Set your own target file size

User Experience

  • 100% Client-Side - Your files never leave your device for maximum privacy
  • Drag & Drop Interface - Intuitive file selection with drag and drop support
  • Batch Processing - Compress multiple files at once with parallel processing
  • Real-time Progress - Visual progress indicators with detailed statistics
  • Responsive Design - Works perfectly on desktop, tablet, and mobile devices
  • Detailed Analytics - Compression ratio, processing speed, and size savings

πŸ› οΈ Technologies & Libraries

Core Technologies

  • HTML5 - Modern semantic markup with Web Workers support
  • CSS3 - Advanced styling with animations and responsive design
  • JavaScript (ES6+) - Modern JavaScript with classes, async/await, and Web Workers

Compression Libraries

  • PDF-lib (v1.17.1) - Advanced PDF manipulation and compression
  • PDF.js (v3.11.174) - PDF rendering and page extraction
  • Pako (v2.1.0) - High-performance gzip/deflate compression for text files

Additional Libraries

  • JSZip - ZIP file creation for batch downloads (optional)
  • Font Awesome (v6.4.0) - Modern icons
  • Google Fonts (Inter) - Clean, professional typography

πŸ“‹ Supported File Formats

Category Formats Compression Method
PDF .pdf Image optimization, page rendering, object streams
Images .jpg, .jpeg, .png, .webp, .bmp Quality reduction, scaling, format conversion
Documents .txt, .html, .css, .js, .json, .xml gzip compression with multiple levels
Archives .zip Optimization (planned)

🎯 Compression Algorithms

PDF Compression

  1. PDF.js Rendering - Renders PDF pages to canvas with scaling
  2. Image Optimization - Converts pages to JPEG with adjustable quality
  3. Object Streams - Uses PDF object streams for better compression
  4. Metadata Removal - Strips unnecessary metadata

Image Compression

  1. Canvas Scaling - Reduces image dimensions while maintaining aspect ratio
  2. Quality Control - Adjustable JPEG/WebP quality settings
  3. Format Conversion - Converts to more efficient formats (PNG β†’ JPEG)

Document Compression

  1. Gzip Compression - Industry-standard gzip with levels 1-9
  2. Streaming - Efficient processing for large text files

πŸ“± Browser Compatibility

Browser Minimum Version Web Workers OffscreenCanvas
Chrome 60+ βœ… Yes βœ… Yes
Firefox 55+ βœ… Yes βœ… Yes
Safari 12+ βœ… Yes ⚠️ Limited
Edge 79+ βœ… Yes βœ… Yes

🚦 Getting Started

Quick Start

  1. Clone the repository

    git clone https://github.com/Tranquil666/FILE_COMPRESSOR.git
    cd FILE_COMPRESSOR
  2. Install dependencies

    npm install
  3. Start the development server

    npm run dev
  4. Open in browser

    http://localhost:3000
    

Production Deployment

  1. Build for production

    npm run production
  2. Deploy to your hosting service

    • The application is fully static and can be deployed to any web server
    • Recommended: Vercel, Netlify, GitHub Pages, or Render

πŸ“Š Performance Metrics

Compression Benchmarks

  • PDF Files: 40-70% size reduction (typical)
  • JPEG Images: 30-60% size reduction
  • PNG Images: 50-80% size reduction
  • Text Files: 60-90% size reduction

Processing Speed

  • Single-threaded: ~2-5 MB/s
  • Multi-threaded: ~8-20 MB/s (depends on CPU cores)
  • Web Workers: Up to 4x faster on modern multi-core CPUs

🎨 UI/UX Features

Modern Design

  • Clean, minimalist interface with gradient backgrounds
  • Smooth animations and transitions
  • Card-based layout for better organization
  • Color-coded compression levels

User Experience

  • Clear visual feedback for all actions
  • Progress indicators with file names
  • Detailed compression statistics (ratio, speed, savings)
  • Error handling with helpful messages
  • Responsive design for all screen sizes

Accessibility

  • Semantic HTML structure
  • ARIA labels for screen readers
  • Keyboard navigation support
  • High contrast text
  • Focus indicators

πŸ”’ Security & Privacy

  • 100% Client-Side Processing - Files never uploaded to any server
  • No Data Collection - Zero tracking or analytics
  • Secure by Design - Uses Content Security Policy (CSP)
  • HTTPS Recommended - Secure connections for script loading
  • Rate Limiting - Protection against abuse (100 requests per 15 minutes)

πŸ—οΈ Architecture

Application Structure

FILE_COMPRESSOR/
β”œβ”€β”€ index.html              # Main HTML file with UI structure
β”œβ”€β”€ script-enhanced.js      # Main application logic with multi-format support
β”œβ”€β”€ compression-worker.js   # Web Worker for parallel compression
β”œβ”€β”€ script.js              # Legacy script (deprecated)
β”œβ”€β”€ styles.css             # Complete styling and animations
β”œβ”€β”€ server.js              # Express server with security middleware
β”œβ”€β”€ package.json           # Dependencies and scripts
└── README.md              # Documentation

Web Worker Architecture

  • Main Thread - UI interactions, file management, result display
  • Worker Threads - Heavy compression tasks, PDF processing, image encoding
  • Message Passing - Efficient communication between main thread and workers
  • ArrayBuffer Transfer - Zero-copy data transfer for performance

πŸ”§ Configuration

Compression Settings

Edit presets in script-enhanced.js:

compressionPresets: {
    maximum: { level: 'high', quality: 0.3, scale: 0.5 },
    balanced: { level: 'medium', quality: 0.6, scale: 0.7 },
    quality: { level: 'low', quality: 0.85, scale: 0.9 },
    custom: { level: 'custom', quality: 0.7, scale: 0.8 }
}

Server Configuration

Environment variables in .env:

PORT=3000
NODE_ENV=production
FRONTEND_URL=https://your-domain.com

File Size Limits

Default: 100MB per file. Modify in script-enhanced.js:

const MAX_FILE_SIZE = 100 * 1024 * 1024; // 100MB

🀝 Contributing

Contributions are welcome! Please follow these guidelines:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow ES6+ JavaScript standards
  • Maintain browser compatibility
  • Write clean, documented code
  • Test on multiple browsers
  • Optimize for performance

πŸ“ Changelog

Version 2.0.0 (Current)

  • ✨ Added multi-format support (PDF, images, documents)
  • ✨ Implemented Web Workers for parallel processing
  • ✨ Added advanced compression algorithms (Brotli, gzip)
  • ✨ Enhanced compression presets (Quality, Balanced, Maximum)
  • ✨ Added detailed compression analytics
  • ✨ Improved PDF compression with image optimization
  • πŸ› Fixed compression ratio calculations
  • πŸ› Improved error handling
  • πŸ’„ Updated UI for multi-format support
  • πŸ“ Enhanced documentation

Version 1.0.0

  • Initial release with PDF compression
  • Basic compression levels
  • Drag and drop interface
  • Batch processing

πŸ› Known Issues

  • Safari: Limited OffscreenCanvas support (falls back to regular Canvas)
  • Large files (>50MB): May cause memory issues on low-end devices
  • Custom target size: May not be achievable for all file types

πŸ—ΊοΈ Roadmap

  • Add support for more image formats (TIFF, SVG)
  • Implement ZIP file optimization
  • Add real-time compression preview
  • Support for video compression
  • Progressive Web App (PWA) support
  • Compression quality comparison tool
  • Cloud save feature (optional)
  • Command-line interface (CLI)

πŸ“„ License

MIT License - see LICENSE file for details

πŸ‘€ Author

Faisal

  • Built with ❀️ for better file management

πŸ™ Acknowledgments

  • PDF-lib - Excellent PDF manipulation library
  • PDF.js - Mozilla's PDF rendering library
  • Pako - Fast zlib port to JavaScript
  • Font Awesome - Icon library
  • Google Fonts - Inter font family

πŸ“§ Support

For issues, questions, or suggestions:

  • Open an issue on GitHub
  • Check existing documentation
  • Review closed issues for solutions

πŸ”— Links


Star ⭐ this repository if you find it helpful!

Built with modern web technologies for fast, secure, and efficient file compression.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages