Most "free" file sites work the same way: you upload your photo or PDF, their server does the work, and you download the result. It works, but it's slow on a bad connection, there's usually a daily limit, and you're handing private files (ID scans, contracts, family photos) to a server you know nothing about.
When I started building DockFlip , I wanted to see how far I could get without a server ever touching the file. Turns out: pretty far. Here's how the main pieces work.
1. Compressing an image to an exact size (like "under 100 KB")
Forms love limits like "max 100 KB". Most compressors give you a quality slider and you guess.
The browser can already do the hard part:
Decode the file with createImageBitmap()
Draw it to a <canvas>
Re-encode it with canvas.toBlob(callback, 'image/jpeg', quality)
To hit a target size, I search for the quality instead of guessing: try the middle, check the blob size, move up or down, repeat a few times.…