How Luban 2's compression algorithm works
masterLuban 2 uses an Adaptive Unified Image Compression algorithm that mimics WeChat Moments' behavior. It adjusts strategies based on image characteristics:
Resolution Decisions
- 1440p Baseline: Uses 1440px as the default short-side baseline.
- Panorama Strategy: For ultra-wide panoramas (long side > 10800px), it locks the long side to 1440px.
- Mega-Pixel Protection: Images > 41MP receive 1/4 downsampling. Ultra-long screenshots are capped at 10.24MP to prevent OOM errors.
Bitrate Control
- < 0.5MP: Minimal lossy compression.
- 0.5-1MP: Enhanced encoding quality.
- 1-3MP: Balanced coefficients.
- > 3MP: High compression ratios.
Robustness
- Inflation Fallback: If the compressed file is larger than the original, the original is returned.
- Format Handling: Preserves transparency for small PNGs; converts large PNGs to JPEG.
- Input Defense: Safely handles extreme resolutions (0, negative, 1px).