Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image Compressor - Smart File Size Reduction (Lossy)

A web-based image compression tool that actually reduces file size using quality-based compression.

Features

  • Real Size Reduction - Compresses files using lossy compression
  • Quality Control - Adjust compression level (10-100%)
  • Multiple Formats - JPEG (best compression), WebP (modern), PNG (quality)
  • Before & After - See exact file size savings
  • Visual Preview - Compare quality side-by-side
  • Smart Resizing - Reduce dimensions for extra savings
  • Drag & Drop - Easy file upload
  • Instant Download - Save compressed images

How It Works

Compression Methods

  1. JPEG Compression (BEST for size reduction)

    • Uses lossy compression algorithm
    • Quality setting: 10-100%
    • Typically reduces file size by 60-90%
    • Best for: Photos, complex images
  2. WebP Compression

    • Modern format with better compression
    • Quality setting: 10-100%
    • Smaller than JPEG at same quality
    • Best for: Modern websites
  3. PNG Format

    • Maintains better quality
    • Less compression than JPEG
    • Supports transparency
    • Best for: Graphics, logos, screenshots
  4. Dimension Reduction

    • Reduces pixel count
    • Major file size reduction
    • Maintains aspect ratio
    • Best for: Large images

this tool uses:

  • Lossy compression - Removes imperceptible data
  • Quality control - You choose size vs. quality trade-off
  • Smart algorithms - Canvas API with optimized encoding
  • Format conversion - Converts to more efficient formats

File Structure

compression-website/
├── index.html          # Main HTML structure
├── style.css           # External CSS styling
├── compression.js      # Compression algorithms
├── script.js           # UI and event handling
└── README.md           # Documentation

Usage Guide

  1. Upload Image

    • Drag & drop or click to browse
    • Supports: PNG, JPG, JPEG, WebP
  2. Choose Settings

    • Format: JPEG for max compression
    • Quality: Lower = smaller file (try 70-85%)
    • Resize: Enable for large images
  3. View Results

    • See exact size reduction percentage
    • Compare before/after visually
    • Download compressed file

Typical Results

Original Size Quality Format Final Size Savings
5 MB 85% JPEG 800 KB 84%
3 MB 75% JPEG 400 KB 87%
2 MB 85% WebP 300 KB 85%

Tips for Best Compression

  1. For Photos: Use JPEG format with 70-85% quality
  2. For Web: Use WebP format with 80% quality
  3. For Large Files: Enable resizing to 1920px width
  4. Lower Quality: Try 60-70% for social media posts
  5. Keep Quality High: Use 90%+ only if size doesn't matter

Browser Requirements

  • Modern browser with Canvas API support
  • Chrome, Firefox, Safari, Edge (latest versions)
  • JavaScript enabled

Limitations

  • Maximum file size: 10MB (browser memory)
  • Processing happens in browser (no server)
  • Very large images may be slow
  • Quality loss is intentional (that's how compression works!)

Understanding Compression

Lossy vs Lossless:

  • Lossless = No quality loss, but minimal size reduction
  • Lossy = Some quality loss, but HUGE size reduction

This tool uses lossy compression because that's what actually makes files smaller! The quality slider lets you balance size vs. quality.

License

Free to use for educational purposes.

About

Loseless Compression using Discrete Cosine Transform and Huffman Coding

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages