Free and Open Source Image Compressor. Optimizes images locally, delivering unmatched efficiency without storing a single file. Experience lightning-fast compression, all in one place.
https://image-compressor.github.io
This project uses a modern, modular architecture with clear separation of concerns. The codebase is organized into focused components, custom hooks, and utility functions for optimal maintainability and testability.
├── public/ # Static assets and PWA manifest
│ ├── logo.png # Application logo variants
│ ├── logo.svg # SVG logo files
│ ├── manifest.json # PWA manifest configuration
│ └── fonts/ # Custom font files
├── src/ # Frontend source code (React + TypeScript)
│ ├── components/ # React components
│ │ ├── ui/ # Reusable UI components (shadcn/ui)
│ │ ├── action-buttons.tsx # Download/Reset functionality
│ │ ├── compressed-images-grid.tsx # Grid display for results
│ │ ├── drop-zone.tsx # File upload interface
│ │ ├── image-preview-card.tsx # Individual image preview
│ │ ├── image-quality-slider.tsx # Compression quality control
│ │ ├── loading-spinner.tsx # Loading states
│ │ ├── theme-provider.tsx # Dark/light theme support
│ │ └── [other components]
│ ├── hooks/ # Custom React hooks
│ │ ├── useDragAndDrop.ts # Drag & drop functionality
│ │ └── useImageCompression.ts # Core compression logic
│ ├── lib/ # Utility libraries
│ │ └── utils.ts # Common utility functions
│ ├── types/ # TypeScript type definitions
│ │ └── image-compressor.ts # Core type interfaces
│ ├── utils/ # Utility functions
│ │ ├── download.ts # File download utilities
│ │ ├── file-validation.ts # File type validation
│ │ ├── image-compression.ts # Image processing logic
│ │ └── utils.ts # General utilities
│ ├── App.tsx # Main application component
│ ├── main.tsx # Application entry point
│ └── index.css # Global styles
├── src-tauri/ # Tauri backend (Rust)
│ ├── src/ # Rust source code
│ │ ├── lib.rs # Library functions
│ │ └── main.rs # Application entry
│ ├── icons/ # Application icons for platforms
│ ├── capabilities/ # Tauri security capabilities
│ ├── gen/ # Generated build files
│ │ └── android/ # Android-specific build files
│ ├── Cargo.toml # Rust dependencies
│ ├── tauri.conf.json # Tauri configuration
│ └── build.rs # Build script
├── package.json # Node.js dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── vite.config.ts # Vite build configuration
├── eslint.config.js # ESLint linting rules
└── components.json # shadcn/ui components configuration
- Purpose: Main container that orchestrates the entire compression workflow
- Size: Optimized from ~410 lines to ~70 lines through modular design
- Responsibilities: Layout management, scroll behavior, component coordination
- Purpose: Handles file upload via drag & drop or file input
- Features: Visual drag feedback, file validation, multi-file support
- Integration: Works with
useDragAndDrophook and file validation utilities
- Purpose: Provides download and reset functionality
- Features: ZIP download, individual image download, state reset
- Platform Support: Tauri-compatible download handling
- Purpose: Displays compressed images in a responsive grid
- Features: Empty state handling, individual image actions, responsive layout
- Purpose: Core compression logic and state management
- State: Compressed images, ZIP files, loading states, progress tracking
- Methods:
handleImageUpload,onImageQualityChange,resetCompression
- Purpose: Drag and drop functionality management
- Features: Drag state tracking, event handling, file validation integration
- Exports:
ALLOWED_FORMATS,validateFileType,filterValidFiles - Purpose: Comprehensive file type validation and error handling
- Exports:
compressImage,processImages - Purpose: Core image processing with progress tracking
- Exports:
downloadZip,downloadSingleImage - Purpose: Cross-platform file download (Tauri & web compatible)
- Exports:
CompressedImage,ImageCompressorState - Purpose: Type-safe interfaces for all components and utilities
- 🎯 Modular Architecture: Each component has a single responsibility
- 🔧 Type Safety: Full TypeScript integration with strict typing
- 📱 Cross-Platform: Tauri-based desktop app with web fallback
- 🎨 Modern UI: shadcn/ui components with dark/light theme support
- ⚡ Performance: Optimized compression with progress tracking
- 🧪 Testable: Isolated components and utilities for easy testing
- 🔄 Reusable: Components can be used across different parts of the app
// Import individual components
import { ImageCompressor, DropZone, ActionButtons } from "./components";
import { useImageCompression, useDragAndDrop } from "./hooks";
import { validateFileType, downloadZip } from "./utils";
// Or import from main index
import {
ImageCompressor,
useImageCompression,
CompressedImage,
} from "./image-compressor";- Node.js version
20+andnpminstalled on your machine - For Tauri development: Rust toolchain installed
# Clone the repository
git clone https://github.com/abue-ammar/image-compressor.git
cd image-compressor
# Install dependencies
npm install
# Start development server
npm startOpen your browser and go to http://localhost:3000 to use the image compressor.
# Development
npm start # Start development server
npm run dev # Alternative development command
# Building
npm run build # Build for production
npm run preview # Preview production build
# Tauri (Desktop App)
npm run tauri dev # Start Tauri development
npm run tauri build # Build desktop application
# Code Quality
npm run lint # Run ESLint
npm run type-check # Run TypeScript compiler check- Frontend Development: Use
npm startfor hot-reload React development - Desktop App Development: Use
npm run tauri devfor Tauri development - Testing: Run individual component tests with the modular structure
- Building: Use
npm run buildfor web ornpm run tauri buildfor desktop
- Zero Dependencies for Core Functionality: No external image processing libraries
- Privacy First: All processing happens locally, no data leaves your device
- Cross-Platform: Runs in browsers and as a desktop application
- Modern Stack: React 18, TypeScript, Vite, Tauri, shadcn/ui
- Optimized Performance: Efficient compression algorithms with progress tracking
- 🖼️ Multi-Format Support: JPEG, PNG, WebP, and more
- 🎚️ Quality Control: Adjustable compression levels with live preview
- 📦 Batch Processing: Compress multiple images simultaneously
- 💾 Flexible Downloads: Download individual images or ZIP archives
- 🖱️ Drag & Drop: Intuitive file upload interface
- 📱 Responsive Design: Works on desktop and mobile devices
- 🌙 Dark/Light Theme: Automatic theme switching support
- 🔒 Privacy Focused: All processing happens locally in your browser
- ⚡ Fast Performance: Optimized compression algorithms
- 🖥️ Desktop App: Available as a native desktop application via Tauri
We welcome contributions! Here's how you can help:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Install dependencies:
npm install - Start development:
npm start - Make your changes
- Test thoroughly
- Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow TypeScript best practices
- Use the existing component structure
- Maintain the modular architecture
- Add proper type definitions
- Write meaningful commit messages
- Test components in isolation
- Verify cross-platform compatibility (web + Tauri)
- Test with various image formats and sizes
- Ensure accessibility standards are met
- New image formats support
- Performance optimizations
- UI/UX improvements
- Mobile responsiveness
- Accessibility enhancements
- Documentation improvements
This project is licensed under the MIT License - see the LICENSE file for details.