This page's code did not start.

Opening index.html directly from a folder blocks JavaScript modules, so nothing will happen when you choose a photo of a page. Serve the folder over http instead:

powershell -ExecutionPolicy Bypass -File serve.ps1

Then open http://localhost:8080/.

Document Scanner — a photo of a page, straightened

Photograph the page. Get back something that looks scanned.

Language: English
View source
Your documents are processed in your browser. No processing upload.

The photo is decoded, straightened, cleaned up and written into a PDF by your own browser, using nothing but arithmetic and the codecs it already ships with. This tool has no network feature of any kind — nothing to fetch, nothing to send — and the reason that matters here is what people photograph pages of: a passport, a payslip, a lease, a form an office asked them to “scan and return”.

Live check: checking…

Offline: checking…

Don't take our word for it: open DevTools, watch the Network tab, and scan a page. Not one request carries a photo, a thumbnail, a filename, or the position of a single corner. Or unplug from the internet and scan one anyway.

1 Choose the photos

A photo of each page, taken from anywhere above it. The whole page has to be in the frame, and the four corners want to be visible or nearly so — everything else, the angle, the shadow, the desk it is lying on, is what this tool is for. Add several and they become the pages of one document, in the order you add them.

2 Put the corners on the page

Press anywhere on the photo and the nearest corner comes to your finger; drag it onto the corner of the page. Tab reaches a corner from the keyboard, the arrow keys move it one pixel and Shift ten. Nothing here is final — the scan is taken from wherever the four corners end up.

Choose a photo and it appears here, with its four corners found for you.

3 Clean it up

What is below is the real result, produced by the same code that writes the file — straightened, and with the uneven light divided out. It is drawn at screen size while you choose; the file itself is made at the photo's own resolution.

Colour, evened out The paper is measured across the page and divided out, so the shadow goes and the paper comes back white, while a stamp, a signature in blue ink or a highlighted line stays the colour it was. The one to use when the colour is part of the document.

Greyscale The same evening-out, without the colour. Smaller than colour and kinder to a photograph or a signature than black and white is.

Black and white Every pixel is decided against its own surroundings rather than against one number for the whole page, which is what keeps the writing in a shadow readable. This is what makes a scan small: a twenty page contract comes out under a megabyte this way and at something like fifteen as photographs. It has no half tones, so anything with a photograph on it should not use it.

Leave it alone Straightened and nothing else. For a page where the paper itself matters — something old, something coloured, a photograph.

The straightened page appears here once there is a photo to straighten.

4 Save the document

The PDF is written here, in this page's memory, a page at a time. There is no server on the other end of this tool to send a payslip, a passport or a contract to, and nothing in the code that would send one if there were.

Print resolution How large a sheet a given number of pixels is called. It changes the size the document prints at, and not one pixel of the scan.

Largest side A ceiling on the straightened page. A photograph of a page holds far more pixels than the page is worth, and 2400 down the long side is about 200 DPI on A4.

Quality For the colour and greyscale modes, which are stored as JPEG. Black and white pages are stored exactly, so this does nothing to them.

Document title (optional) The PDF records this tool’s name and any title you enter, without a date, author or machine information.

82%

View as Markdown

How to scan a document with your phone camera

  1. Photograph the page. From above, with the whole page in the frame and the four corners visible or nearly so. It does not have to be square-on and it does not have to be evenly lit: the angle and the shadow are what this tool is for. What does matter is filling the frame — a page photographed from across the room has no detail in it to recover.
  2. Check the four corners. They are found for you when the photo is read, and the page says so when it is not sure — a page on a desk the same colour as the paper is genuinely hard to see the edge of. Press anywhere on the photo and the nearest corner comes to your finger, or reach one with Tab and move it with the arrow keys.
  3. Choose what to do with the light. “Colour, evened out” measures the paper across the page and divides it out, so the shadow goes and a stamp or a signature keeps its colour. “Black and white” goes further and is what makes a scan small enough to email. What you see on screen is the real result, produced by the same code that writes the file.
  4. Add the other pages. Every photo you add becomes another page of the same document, in the order they are listed, and each one keeps its own corners. The arrows on a page in the strip move it earlier or later.
  5. Save the PDF, and open it before you send it. The document is written here, in this page's memory. Nothing was uploaded to make it, and nothing about it was reported anywhere.

The longer version

How to scan a document with your phone What separates a photograph of a page from a scan of one: the angle, the uneven light, and the file size. How to take the photo, what to fix afterwards, and why none of it needs a server.

Questions

Is my document uploaded anywhere?

No. The photo is decoded, straightened, cleaned up and written into a PDF by your own browser on your own hardware. This tool has no network feature of any kind — it never fetches anything and never sends anything — and the page's Content-Security-Policy names every address it may contact, none of which belongs to this site. Load the page once, unplug from the internet, and it still works.

How does it find the corners of the page without a model?

By looking for the four long straight edges a rectangle is made of. The photo is shrunk, the gradient is taken — where the picture changes, and in which direction — and every pixel that sits on an edge votes for the straight line it would lie on. The strong lines are paired into candidate rectangles, and each candidate is scored by walking its four sides and asking how much of each one really has an edge under it, and whether the four of them are the boundary of one thing: a page is lighter than what is around it, or darker, but it is the same one on all four sides, which is what stops a line of text being mistaken for the bottom of the page. There are no weights, nothing is downloaded, and the arithmetic is the same arithmetic for every document put through it.

The corners it found are wrong. What now?

Drag them. The corners are a starting position and never a decision: the scan is taken from wherever the four of them end up. Press anywhere on the photo and the nearest corner jumps to your finger, which is easier than hitting a small handle, and the arrow keys move the focused corner one pixel at a time. The page also tells you when the corners are a guess rather than a finding, and marks that page in the strip — a page lying on a desk of about its own colour is the usual reason, because there is genuinely almost no edge there to find.

Why does the straightened page come out the right shape, and not squashed?

Because the shape is recovered from the perspective rather than measured off the edges. A page photographed at an angle has its far edge foreshortened, so the obvious method — take the longest pair of opposite edges and call that the ratio — produces a visibly squat A4, which is what most web scanners give you. A photograph of a rectangle actually carries enough information to recover both the rectangle's aspect ratio and the camera's focal length, given only that the camera is an ordinary one; that is a result of Zhang and He's from 2003, and it is what src/shared/document-geometry.js does. Where the photo was taken square-on there is no perspective to work from and none is needed, because the edges are then exact — so it falls back to them, and the page says which of the two answered.

What does “cleaned up” actually do to the picture?

It divides out the light. The paper's own brightness is measured across the page — a grid of tiles, and in each tile a high percentile of the brightness, which text is too dark and too sparse to move — and every pixel is divided by the paper estimated at that point. What is left is the ink, evenly lit, with the shadow and the falloff gone. That is not the same as raising the contrast: raising the contrast of a photographed page makes the bright part white, the dark part black, and the writing in the dark part unreadable, which is why “auto levels” makes these pictures worse rather than better.

Why is the black and white mode so much smaller?

Because a picture with two colours in it is genuinely a fraction of the data of a picture with sixteen million, and it is stored that way here: one bit per pixel, packed eight to the byte and compressed exactly, rather than as a JPEG of a black and white picture. On the same pages it comes out about eighteen times smaller than the colour mode does, so a twenty page contract lands under a megabyte rather than at something like fifteen. The threshold is Sauvola's, which decides each pixel against the mean and the spread of its own neighbourhood rather than against one number for the whole page — that is what keeps the writing inside a shadow. It has no half tones, so a page with a photograph on it should use one of the other modes.

Can I put several pages in one PDF?

Yes. Every photo you add becomes another page, in the order they are listed, and each page keeps its own corners — so a stack of pages photographed one after another becomes one document. The arrows on each page in the strip move it earlier or later. The cleanup setting is shared by all of them on purpose: pages in one document that were cleaned up differently look like two documents.

Does it read the text, so I can search the PDF?

No. There is no text layer and no character recognition: what comes out is a picture of the page on a page. Doing it properly would mean an OCR engine, which is tens of megabytes of model to download — and a document scanner that fetched a model before it could read your payslip would be a document scanner that had a reason to phone home about payslips. If you need the text, the black and white mode produces exactly the sort of file that OCR software on your own machine works best on.

It came out blurry. Why?

Almost always because the page was small in the photo. The panel under the preview says how much of the frame the page filled and roughly how many dots per inch that works out at across a sheet of that size — below about 150 DPI a printed scan looks soft, and there is nothing any tool can do about detail that was never in the file. Move closer rather than zooming, hold still, and let the camera focus on the page before pressing the button. Camera shake is the other cause, and it is not recoverable either.

Is it free, and do I need an account?

It is free, and there is no account, no sign-in, no trial, no page limit and no watermark. There is no limit on the size of the photos either, because there is no server paying for it — the work happens on your own machine. The site carries advertising, which is what pays for it; the ads are not given anything about your documents.