How Browser-Side File Processing Works: File API, Canvas, toBlob and Web Workers
Many online tools upload your file to a server, process it there and send back the result. Others – including the image, PDF and Hindi tools on Crop Desk – do the work inside your own browser, so the file never leaves your device. This article explains the web platform features that make that possible, as documented by the W3C File API specification and MDN Web Docs. It is useful for B.Tech CS/IT students learning front-end engineering, and for anyone who wants to check a tool's privacy claim for themselves.
In short: when you pick a file, the page gets a File object (a kind of Blob) that it can read locally. Images are decoded, drawn on a <canvas>, edited, and exported with canvas.toBlob(). Heavy work such as PDF rendering or OCR runs in Web Workers. The result is given back as a download through an object URL. None of this needs a network request.
Step 1: getting the file – File and Blob
An <input type="file"> element, or a drag-and-drop, gives the page a list of File objects. The W3C File API defines Blob as immutable raw data and File as a Blob with a name and a last-modified date. Selecting a file does not upload it. It only lets the page's own script read it.
| API | What it gives you | Typical use |
|---|---|---|
file.arrayBuffer() | Raw bytes | Parsing PDFs, reading EXIF, checking a file signature |
FileReader.readAsDataURL() | A Base64 data: URL | Small previews (about 33% larger than the file – see Base64 explained) |
file.text() | Text, decoded as UTF-8 | CSV, TXT, Kruti Dev text files |
URL.createObjectURL(file) | A short blob: URL pointing at the data in memory | Showing a large image or offering a download without copying it |
MDN notes that object URLs should be released with URL.revokeObjectURL() when no longer needed, otherwise the memory stays in use until the page closes.
Step 2: decoding and editing images on a canvas
- The browser decodes the JPG, PNG or WebP into pixels. HEIC needs an extra decoder in many browsers – see HEIC to JPG.
- The script calls
drawImage()on a canvas of the target size, for example 200 × 230 for an exam photo. That single call does the crop and the resize. The browser's smoothing setting decides the interpolation – see how image resizing works. - Filters such as brightness, a white background or a name-and-date strip are drawn or computed on the same canvas.
Step 3: encoding the output with toBlob()
MDN documents canvas.toBlob(callback, type, quality). type is the output format: image/png is the default and must be supported, and many browsers also support image/jpeg and image/webp. quality is a number from 0 to 1 for lossy formats. Hitting a target such as "20–50 KB" is therefore a search loop:
quality = 0.92
repeat:
blob = encode(canvas, "image/jpeg", quality)
if blob.size <= target: stop
quality = quality − step (or shrink dimensions if quality gets too low)
A smarter tool uses binary search on quality and keeps the largest file under the limit, which gives the best quality that still fits. Why lower quality means fewer bytes is explained in how JPEG compression works.
One detail matters for forms. MDN notes that images created by toBlob() get a resolution of 96 dpi in formats that store resolution metadata. If a portal checks the DPI field, a separate step has to rewrite that header. Crop Desk's image DPI converter does exactly that. DPI explained covers when it matters.
Step 4: heavy work in Web Workers
JavaScript on a page normally runs on one main thread, which also handles clicks and scrolling. MDN describes Web Workers as a way to run scripts in background threads, so long jobs do not freeze the page. Typical worker jobs:
- PDF rendering and parsing, for example with Mozilla's PDF.js, which uses a worker.
- OCR with Tesseract.js, which runs the recognition engine in a worker (see what is OCR).
- Batch jobs such as compressing 50 photos for a school ZIP.
Some libraries download their code or language data the first time you use them. For example, an OCR tool may fetch a Hindi language model. That is a download to your device, not an upload of your file.
Step 5: giving the result back
The finished Blob is turned into an object URL and linked from an <a download="photo_200x230.jpg"> element. Clicking it saves the file from memory. No server ever had a copy.
How to check a "nothing is uploaded" claim yourself
- Open the browser's developer tools (F12 or Ctrl+Shift+I) and go to the Network tab.
- Clear the list, then pick your file and run the tool.
- Look at the new requests. Analytics pings and script or font downloads are small, contain no file data, and are not POST requests carrying your file. A request whose size is close to your file's size, sent to a server, means the file was uploaded.
- For a stronger test, load the tool, switch the device to aeroplane mode, and run it. A truly client-side tool keeps working for features that need no new downloads.
Limits of client-side processing
| Limit | Why | What tools do |
|---|---|---|
| Memory | A 4000 × 3000 photo decodes to 4000 × 3000 × 4 bytes ≈ 48 MB of pixels (RGBA) | Process large batches one by one |
| Speed on old phones | Everything runs on your own CPU | Use workers and show progress |
| Format support | Browsers do not all decode HEIC or export WebP | Bundle a decoder, or fall back to JPG/PNG |
| Big PDFs | Rendering hundreds of pages is heavy | Process page by page |
For privacy, client-side is the safer design for documents such as admit cards, Aadhaar, marksheets and signatures. Why browser-only tools are safer covers the practical side. EXIF metadata and privacy explains what a photo file can reveal even before it is uploaded anywhere.
Frequently asked questions
Does choosing a file on a website upload it?
No. Selecting a file only gives the page's script access to it. An upload happens only if the script sends it over the network.
How can I check that a tool does not upload my file?
Open developer tools, go to the Network tab, run the tool, and look for a request about the size of your file. Running the tool offline is a further test.
Why do in-browser images show 96 dpi?
MDN notes that canvas toBlob() output gets a resolution of 96 dpi in formats that store resolution metadata. A DPI tool can rewrite that header.
Sources
- W3C – File API (File, Blob, FileReader, blob URLs)
- MDN Web Docs – FileReader
- MDN Web Docs – HTMLCanvasElement.toBlob()
- MDN Web Docs – URL.createObjectURL()
- MDN Web Docs – Web Workers API
- MDN Web Docs – <input type="file">
Sources checked on 23 November 2026. Official notices and orders change; the latest version on the issuing body's website is final.