Optimization Techniques

Hitting Strict Compression Targets (20KB, 50KB, 100KB)

How adaptive quantization loops work, what causes compression to fail, and how to configure settings for guaranteed success.

The Challenge of Hard File-Size Ceilings

Many government portals, visa applications, and university admissions systems enforce uncompromising file size limits. A file that is even 1 byte over the 50 KB ceiling (51,201 bytes) is rejected with generic errors like “Upload failed: File exceeds allowable size.”

Common Compression Pitfalls

  • Rounding Errors: Many tools display rounded values like “49.8 KB” based on 1 KB = 1000 B, while the destination server validates against binary 1,024 B (50 KB = 51,200 bytes). If the actual file is 51,300 bytes, it will be rejected.
  • Oversized Fallbacks: Some poorly built web resizers resolve their last compression attempt even if it remains oversized, falsely marking the operation as successful.
  • Lossless Formats: PNG is mathematically lossless. Trying to compress a 400 × 400 complex photo into a 20 KB PNG is physically impossible without losing resolution, because PNG cannot use lossy quality steps.

How ApplyReady’s Strict Compressor Works

ApplyReady uses an adaptive quality search algorithm:

  1. Initial Render: Your image is cropped and drawn at the exact target dimensions (e.g. 350 × 450 px).
  2. Stepped Quantization: The engine encodes the canvas with high quality (0.95). If the resulting byte count exceeds your target limit, it automatically tries lower steps (0.85, 0.75, 0.65, 0.50, 0.35, 0.20, 0.10, 0.05).
  3. Honest Error Reporting: If even at minimum quality (0.05) the file exceeds the target, ApplyReady never reports false success or silently shrinks dimensions. Instead, it informs you clearly of the actual size achieved and suggests actionable remedies (such as reducing width/height or selecting WebP).
  4. Byte-Level Verification: Before displaying the download link, the encoded blob's actual size in bytes is compared to maxKB × 1024.

Practical Recommendations for Common Limits

Target Limit Recommended Resolution Format
Under 20 KB (Signatures / Icons) 140 × 60 px up to 300 × 100 px JPEG / WebP
Under 50 KB (Passport / ID Photos) 350 × 450 px or 200 × 230 px JPEG / WebP
Under 100 KB (Avatars / Badges) 400 × 400 px up to 600 × 600 px JPEG / WebP

Resize Your Image Under Strict Limits