Skip to main content

What is Auto-Compression?

Auto-compression automatically reduces image file sizes before upload, saving storage space while maintaining visual quality. This feature can reduce file sizes by 40-70% with minimal quality loss.
Only images are compressed. Videos are uploaded at their original quality to preserve playback performance.

How It Works

When auto-compression is enabled:
  1. You upload an image
  2. Imperial compresses it using Sharp (industry-leading image processor)
  3. Compressed version is stored and served
  4. You only pay for the compressed size

Original

2.4 MB

Compressed

→ Quality 65

Result

1.1 MB (54% smaller)

Quality Levels

Choose the right quality level for your use case:
Best for: Photography, portfolio work, detailed images
  • Minimal compression (~40% size reduction)
  • Virtually no visible quality loss
  • Preserves fine details and gradients
  • Recommended for professional use
Example:
  • Original: 3.2 MB → Compressed: 1.9 MB

Enabling Auto-Compression

1

Open Settings

Navigate to Settings → Uploads in your dashboard
2

Enable Auto-Compress

Toggle Auto-Compress Images to ON
3

Choose Quality

Select your preferred quality level (50-100)
4

Save Changes

Settings apply to all future uploads
Already uploaded images aren’t affected. Compression settings only apply to new uploads.

Supported Formats

Compression works on these image formats:
FormatCompressionNotes
JPEG✅ YesMost effective compression
PNG✅ YesGood compression, preserves transparency
WebP✅ YesAlready efficient, minor gains
GIF❌ NoAnimated GIFs uploaded as-is
Videos❌ NoAll formats uploaded at original quality

Visual Comparison

Here’s how different quality levels affect a typical photo:
File size: 3.2 MB
Quality: Perfect
Use case: Archives, print work
Full detail preserved, maximum file size.

When to Use Compression

  • Screenshots - Often contain large areas of solid color (excellent compression)
  • Web Graphics - UI elements, icons, social media images
  • General Photography - Personal photos, blog images
  • High-Volume Uploads - Maximize your storage capacity
  • Print Work - When you need maximum quality for physical prints
  • Archival - Original quality preservation is critical
  • Already Compressed - Files from modern cameras/phones are already optimized
  • Medical/Scientific - When detail accuracy is essential

Storage Savings Calculator

Estimate your savings based on typical usage:
Monthly uploads: 50 images @ 2 MB each
QualitySize per ImageTotal StorageSavings
Original2.0 MB100 MB-
High (80)1.2 MB60 MB40%
Balanced (65)0.9 MB45 MB55%
Optimized (50)0.6 MB30 MB70%

API Usage

Check Compression Settings

Compression is automatically applied based on your dashboard settings. No additional parameters needed:
curl -X POST https://api.imperial.gay/images/upload \
  -H "Authorization: Bearer YOUR_KEY" \
  -F "[email protected]"

Response Includes Compression Info

{
  "uploaded": [
    {
      "_id": "67d8f9a1b2c3d4e5f6789012",
      "url": "https://cdn.imperial.gay/uploads/...",
      "filename": "photo.jpg",
      "originalFilename": "photo.jpg",
      "fileSize": 921600,
      "originalFileSize": 2048000,
      "compressed": true,
      "compressionQuality": 65,
      "mimeType": "image/jpeg"
    }
  ]
}
fileSize is what counts toward your storage limit. originalFileSize is just for reference.

Performance Impact

Compression happens server-side and adds minimal latency:
File SizeCompression TimeImpact
< 1 MB~50msNegligible
1-5 MB~100-200msMinor
5-10 MB~300-500msNoticeable
> 10 MB~500ms+Consider pre-compression
For very large files or batch uploads, consider compressing images before upload using tools like ImageOptim, TinyPNG, or Squoosh.

Advanced Tips

Format-Specific Optimization

  • Most efficient format for compression
  • Quality 65-80 recommended for photos
  • Quality 50-65 for screenshots
  • Progressive encoding used automatically
  • Transparency preserved at all quality levels
  • Text and sharp edges remain crisp
  • Larger files benefit most from compression
  • Compression level 9 (maximum) used automatically
  • Already highly compressed format
  • Compression provides 10-30% additional savings
  • Maintains superior quality-to-size ratio
  • Recommended for modern web applications
  • Animated GIFs bypass compression
  • Static GIFs converted to PNG with compression
  • Consider converting GIFs to video for better results

Bulk Optimization

If you have many uncompressed files:
  1. Download originals from dashboard
  2. Re-upload with compression enabled
  3. Delete uncompressed versions to reclaim storage
Or use our bulk re-compress feature (coming soon).

Testing Quality Levels

Try different quality levels with the same image:
# Upload with current settings
curl -X POST https://api.imperial.gay/images/upload \
  -H "Authorization: Bearer YOUR_KEY" \
  -F "[email protected]"

# Check response to see compressed size
# Adjust quality in dashboard
# Upload again to compare

Frequently Asked Questions

No. Compression only reduces file size. Width and height remain unchanged.
No. If compression is enabled, all images are compressed. Disable it in settings for specific uploads.
Transparency is fully preserved at all quality levels. Alpha channels are maintained.
Not currently. Compression happens during upload. Consider re-uploading with new settings if needed.
WebP is already an efficient format. Compression provides diminishing returns compared to JPEG/PNG.
Slightly. Most images add 50-200ms. Network transfer time is usually the bottleneck.

Best Practices

1

Start with Balanced (65)

This provides the best quality-to-size ratio for most use cases
2

Test with Sample Images

Upload test images at different quality levels to find your sweet spot
3

Adjust Per Use Case

Use High (80) for important work, Optimized (50) when maximizing storage
4

Monitor Storage Usage

Check your dashboard to see how much space compression saves
5

Consider Format

JPEG compresses better than PNG for photos. PNG better for graphics with text.