Skip to content

A high-performance web application that compresses images to achieve the smallest possible file size while maintaining visual quality. Built with Next.js, Sharp, and TypeScript using advanced binary search algorithms and intelligent quality adjustment.

Notifications You must be signed in to change notification settings

godwillcodes/PixelPress

Repository files navigation

PixelPress 🎨

Maximum image compression for optimal file sizes

A high-performance web application that compresses images to achieve the smallest possible file size while maintaining visual quality. Built with Next.js, Sharp, and TypeScript using advanced binary search algorithms and intelligent quality adjustment.

✨ Features

  • 🎯 Maximum Compression: Targets the smallest possible file size (minimum 1KB) using intelligent algorithms
  • 🖼️ Format Support: WebP and AVIF output with JPEG/PNG input
  • ⚡ Adaptive Algorithms: Parallel processing with intelligent quality estimation
  • 📐 Progressive Scaling: Dimension reduction when quality adjustment isn't sufficient
  • 📊 Real-time Metrics: Processing time, compression ratio, and iteration tracking
  • 🚀 PWA Support: Install as a Progressive Web App for offline use
  • 💾 Smart Caching: Intelligent caching system for faster subsequent compressions

🚀 Quick Start

# Install dependencies
pnpm install

# Start development server
pnpm dev

# Build for production
pnpm build

🔧 API Usage

curl -X POST http://localhost:3000/api/compress \
  -F "[email protected]" \
  -F "format=webp" \
  -F "mode=balanced" \
  --output compressed.webp

API Parameters

  • image: Input image file (JPEG, JPG, PNG)
  • format: Output format (webp or avif)
  • mode: Compression mode (balanced or exact)

🏗️ Architecture

Core Algorithm

  • 🔍 Binary Search: Quality values (1-100) with tolerance-based convergence
  • ⚡ Parallel Processing: Multiple quality tests for faster optimization
  • 🧠 Adaptive Heuristics: Image complexity analysis for better starting points
  • 📏 Fallback Scaling: Dimension reduction for maximum compression

Technology Stack

Technology Version Purpose Icon
Next.js 15.5.5 React framework with App Router Next.js
React 19.1.0 UI library React
TypeScript 5.0 Type-safe development TypeScript
Sharp 0.34.4 High-performance image processing Sharp
Tailwind CSS 4.0 Utility-first styling Tailwind CSS
Formidable 3.5.4 File upload handling Formidable

📈 Performance

Format Processing Time Compression Ratio Quality Range
WebP 100-300ms 8-15:1 60-95%
AVIF 200-500ms 12-20:1 60-95%

🛠️ Development

# Development commands
pnpm dev          # Start development server
pnpm build        # Production build
pnpm start        # Production server
pnpm lint         # Code linting

🎨 Compression Modes

Balanced Mode (Recommended)

  • Quality Priority: Maintains visual quality with ±5KB tolerance
  • Timeout: 90 seconds
  • Use Case: General purpose compression

Exact Mode

  • Size Priority: Targets minimum possible file size
  • Timeout: 90 seconds
  • Use Case: Maximum compression when file size is critical

🔧 Configuration

The compression behavior can be customized in src/lib/config.ts:

export const COMPRESSION_CONFIG: CompressionConfig = {
  targetBytes: 1_000,        // Minimum possible size (1KB)
  toleranceBalanced: 5_000,  // Balanced mode tolerance
  toleranceExact: 0,         // Exact mode tolerance
  maxFileSize: 25 * 1024 * 1024, // 25MB max input
  maxWallTimeBalanced: 20_000,   // 20 seconds
  maxWallTimeExact: 25_000,      // 25 seconds
};

📱 PWA Features

  • 📲 Installable: Add to home screen on mobile devices
  • 🔄 Offline Support: Works without internet connection
  • ⚡ Fast Loading: Optimized for performance
  • 📊 Performance Dashboard: Real-time compression metrics

🚀 Deployment

Vercel (Recommended)

# Deploy to Vercel
vercel --prod

Docker

# Build Docker image
docker build -t pixelpress .

# Run container
docker run -p 3000:3000 pixelpress

🤝 Contributing

  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

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🌟 Acknowledgments

  • Built with ❤️ using Next.js and Sharp
  • Inspired by the need for maximum image compression
  • Special thanks to the open-source community

PixelPress - Maximum image compression for optimal file sizes

Live Demo GitHub

About

A high-performance web application that compresses images to achieve the smallest possible file size while maintaining visual quality. Built with Next.js, Sharp, and TypeScript using advanced binary search algorithms and intelligent quality adjustment.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published