A privacy-preserving local web application for compressing images to a target file size. All processing happens locally - your images never leave your device.
- Drag & Drop / Paste Support: Easily upload images by dragging, clicking, or pasting (Ctrl+V)
- Multiple Formats: Support for JPEG, PNG, and WebP input/output
- Target Size Compression: Specify target file size in MB (defaults to 1 MB)
- Priority Modes: Choose between size-first or resolution-first optimization
- Smart Compression: Automatic format selection and quality optimization
- Preview & Metadata: See image preview and detailed metadata before compression
- Prediction: Preview estimated output size and dimensions before compressing
- 100% Local: All processing happens in your browser and local Python backend
- Vite - Fast build tool and dev server
- React + TypeScript - UI framework and type safety
- shadcn/ui - Beautiful, accessible UI components
- Tailwind CSS - Utility-first styling
- FastAPI - Modern Python web framework
- Pillow (PIL) - Image processing library
- uvicorn - ASGI server
digital-asset-optimizer/
├── backend/
│ ├── app/
│ │ ├── main.py # FastAPI application
│ │ ├── models.py # Pydantic models
│ │ ├── compress.py # Compression algorithms
│ │ └── utils.py # Utility functions
│ ├── requirements.txt # Python dependencies
│ └── README.md
├── src/
│ ├── api/
│ │ └── client.ts # API client wrapper
│ ├── components/
│ │ ├── DropZone.tsx # File upload component
│ │ ├── PreviewCard.tsx # Image preview
│ │ ├── MetadataPanel.tsx # Image metadata display
│ │ ├── CompressionControls.tsx
│ │ ├── PredictionPanel.tsx
│ │ └── ui/ # shadcn/ui components
│ ├── types/
│ │ └── api.ts # TypeScript types
│ └── App.tsx # Main application
├── vite.config.ts # Vite configuration
└── package.json
- Node.js 18+ and npm
- Python 3.9+
- Navigate to the backend directory:
cd backend- Create a virtual environment:
python -m venv venv
# On macOS/Linux:
source venv/bin/activate
# On Windows:
venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Navigate to the root directory:
cd .. # if you're still in backend/- Install dependencies:
npm installUse the provided start script to launch both servers and open the app automatically:
./start.shThis will:
- Start the backend server on port 8000
- Start the frontend dev server on port 5173
- Automatically open the app in your default browser
- Allow you to stop both servers with a single Ctrl+C
Alternatively, you can run both servers manually:
In the backend/ directory with the virtual environment activated:
uvicorn app.main:app --reload --port 8000The API will be available at http://localhost:8000
In the root directory:
npm run devThe app will be available at http://localhost:5173
- Upload an Image: Drag and drop an image, click to browse, or paste (Ctrl+V) an image from your clipboard
- View Metadata: See the original file size, resolution, and format in the left panel
- Set Target Size: Enter your desired file size in MB (defaults to 1 MB, must be smaller than original)
- Choose Priority Mode:
- Target Size: May reduce quality or resolution to meet size goal
- Optimal Resolution: Preserves resolution, may exceed target size
- Select Output Format: Choose JPEG (default), WebP, PNG, or Auto
- Preview Results: Click "Preview Results" to see estimated output
- Compress: Click "Compress" to process the image
- Download: Download your compressed image (saved as
filename_new.ext)
Get image metadata
- Input: Multipart file upload
- Output: JSON with filename, format, size, dimensions, EXIF info
Estimate compression results
- Input: Multipart file + JSON params (target_bytes, output_format, etc.)
- Output: JSON with predicted dimensions, size, format, and warnings
Compress image and return file
- Input: Multipart file + JSON params
- Output: Binary image file with metadata in headers
The backend uses an intelligent dual-mode compression strategy:
- Priority Mode Selection:
- Target Size: Aggressively reduces resolution and quality to meet target
- Optimal Resolution: Preserves dimensions, adjusts quality only
- Format Selection: Automatically chooses the best format (WebP for aggressive compression, preserves format when possible)
- Progressive Resizing: Tries multiple resize scales (100%, 90%, 80%, 70%, 60%, 50%) based on priority mode
- Quality Binary Search: For lossy formats (JPEG/WebP), performs binary search on quality settings (40-95)
- Best Effort: Returns the closest result with warnings if exact target cannot be met
- 100% Local Processing: Images are processed locally on your machine
- No Cloud Uploads: Your images never leave your device
- No Data Collection: No analytics, tracking, or data collection
- Open Source: Full source code available for review
- JPEG/JPG
- PNG
- WebP
- JPEG (lossy, good compression)
- PNG (lossless, larger files)
- WebP (recommended, best compression)
npm run dev # Start dev server
npm run build # Build for production
npm run preview # Preview production build
npm run lint # Run ESLintuvicorn app.main:app --reload # Development server
uvicorn app.main:app --host 0.0.0.0 --port 8000 # Production server- Batch compression support
- HEIC format support
- Animated GIF support
- Advanced quality controls
- Image cropping/editing
- Comparison view (before/after)
- Download as ZIP for batch operations
MIT License - feel free to use this project for any purpose.
Built with: