Dev.to
7/26/2026

The 50KB Problem: Why Government Forms Keep Rejecting Your Photo
Short summary
Government and exam portals commonly cap photo uploads at 20–200KB, but hitting an exact byte target is a nontrivial optimization problem involving pixel dimensions, image entropy, and compression quality. The solution is a binary search over JPEG quality levels, re-encoding via canvas on each iteration, with pixel-dimension scaling as a fallback. PNG is unsuitable for these limits because lossless compression cannot reliably hit small KB targets.
- •File size is a derived value of dimensions, entropy, and quality—not a directly settable variable
- •Binary search over JPEG quality converges on target byte count in a handful of iterations
- •Common Indian exam portals (SSC, UPSC, IBPS) cap passport photos at 50KB; signatures at 20KB; ID scans at 100KB
Generated with AI, which can make mistakes.
Is this a good recommendation for you?



