From a phone photo to a clean PDF
A photo of a sheet of paper is rarely a good document. The page sits at an angle, the desk shows around it, and the paper looks gray or yellow with a shadow across it. This tool fixes that for every photo before it builds the PDF. You mark the four corners of the paper, the page is straightened into a rectangle, and a filter turns the paper white or the page into crisp black and white. The corners also work as the crop: everything outside them, like the desk, is left out, so there is no separate crop step. You can turn pages, change their order, choose A4, Letter or the size of the image, and save everything as one PDF.
If your images are already clean, for example screenshots or real scans, JPG to PDF puts them into a PDF unchanged. To make the text of the finished PDF searchable, run it through OCR PDF.
How the page is straightened
Any two pictures of the same flat surface are related by a homography, a mapping that takes straight lines to straight lines. It is a 3 × 3 matrix with eight unknown values, and each corner you mark gives two equations, one for x and one for y, so the four corners fix it. The tool solves these eight equations and then builds the new page pixel by pixel: for every pixel of the straight page it computes where that point lies in the photo and mixes the four nearest photo pixels (bilinear sampling).
The size of the straight page comes from the corners you marked. The longest edge sets the long side. The other side follows the shape of the paper, which the tool works out from how the edges converge, using the method of Zhengyou Zhang and Li-wei He for photographed whiteboards. When the paper is tilted in one direction only, the lens cannot be worked out from the photo, so a typical phone lens is assumed, and the shape can be a few percent off. For standard paper, choose A4 or Letter with Stretch to the page, and the page gets the shape of that sheet.
The four filters
| Filter | What it does | Stored as |
|---|---|---|
| Original | Only straightens the page | JPEG |
| Enhanced color | Whitens the paper, even in a shadow, and makes ink stronger; colors stay | JPEG |
| Grayscale | Removes the color | JPEG |
| Black and white | Only black and white, for text pages | 1 bit per pixel, Flate compressed |
Black and white uses the adaptive threshold of Derek Bradley and Gerhard Roth. Instead of one cut-off value for the whole page, each pixel is compared with the average brightness of the square around it, with a side of one eighth of the image width. A pixel at least 15 percent darker than that average turns black, all others white. A shadow darkens the pixel and its surroundings alike, so it does not turn into a black patch. Enhanced color uses the same local average: every pixel is divided by the brightness around it, so the paper ends up at the same level everywhere, and then the contrast is stretched so that paper becomes white and ink gets darker.
Black and white pages are stored in the PDF with 1 bit per pixel and Flate compression instead of JPEG, so no JPEG blur is added around the letters and the file stays small. The other pages are saved as JPEG at the quality you choose.
Page size, image size and quality
- Page size: A4 or Letter turns to landscape for wide scans. Fit inside keeps the proportions and centers the scan; Stretch to the page fills the page. Fit to image makes each page as wide as A4 and as tall as the scan needs.
- Image size: the long side of every scan in pixels. At 2,400 px a full A4 page has about 205 pixels per inch along its long side, and a Letter page about 218; at 1,600 px, about 137 and 145. Full keeps every pixel of the photo, which makes the largest file.
- JPEG quality: lower values make smaller files with more blur around letters.
Worked example
A 12-megapixel phone photo shows a page taken from straight above. After you mark the corners, the top and bottom edges measure up to 2,520 px and the sides up to 3,260 px. With Image size 2,400 px, the straight page is scaled by 2,400 / 3,260 to 1,855 × 2,400 px. On an A4 page with Fit inside, the width decides: the scan is drawn 595.28 points wide and 770.17 points tall, which leaves 35.86 points, about 12.7 mm, of white at the top and bottom, at 1,855 pixels over 8.27 inches, about 224 pixels per inch. With Stretch to the page it fills the whole A4 page instead.
Limits
- No automatic edge detection: you set the corners yourself; Whole photo uses the full picture.
- Curved pages, such as a thick book, stay curved, because the correction assumes a flat sheet.
- Very large photos are scaled down when the browser cannot draw them at full size, which happens sooner on iPhone and iPad. The tool says when this happens.
- The camera button needs a browser that supports it, mostly phones; on a computer it opens the normal file picker.
- Text is not searchable until you run OCR PDF.
How to scan a document to PDF with your phone
- 1Take a photo of each page, or drop photos you already have. HEIC photos from an iPhone work too.
- 2For each page, drag the four handles onto the corners of the paper and turn the page upright if needed.
- 3Pick a filter, put the pages in order with the arrow buttons, and choose the page size.
- 4Press Create PDF. To make it smaller, try Compress PDF.
Sources
- Wikipedia: Homography (computer vision): any two images of the same planar surface are related by a homography
- Zhengyou Zhang and Li-wei He, Whiteboard scanning and image enhancement, Digital Signal Processing 17 (2007): the aspect ratio of a photographed rectangle and the focal length of the camera estimated from its four corners
- Derek Bradley and Gerhard Roth, Adaptive Thresholding Using the Integral Image: each pixel compared with the average of an s × s window, s one eighth of the image width, black when t = 15 percent darker
- MDN: HTML attribute capture: environment asks for the outward-facing camera; limited browser support, a desktop computer usually shows a file picker
Guide on this topic
Frequently asked questions
Are my photos uploaded?
No. Your browser opens the photos, straightens and cleans them and builds the PDF on your own device. Nothing is sent to a server, which matters for receipts, contracts and ID documents.
How is this different from JPG to PDF?
JPG to PDF puts your images into a PDF as they are. Scan to PDF first turns each photo into a clean page: you drag the four corners onto the paper, the tool straightens the page so it is a rectangle again, and a filter whitens the paper or turns the page into crisp black and white.
Which filter should I use?
Enhanced color for most documents: the paper turns white and colored stamps, signatures and logos stay. Black and white for pages with only text, which gives the sharpest print and the smallest file. Grayscale for pages with photos or pencil. Original keeps the photo as it is, only straightened.
Why is the page a little too short or too wide?
A photo taken at an angle does not show the true shape of the paper, so the tool estimates it from the perspective of the corners you marked. When the paper is tilted in one direction only, the estimate rests on a typical phone lens and can be a few percent off. If the page is a standard A4 or Letter sheet, choose that page size and Stretch to the page; the scan then gets the proportions of that paper.
Can I take the photos with my phone camera?
Yes. On a phone, Take a photo opens the camera in most browsers, and Choose photos lets you pick pictures you already took, including HEIC photos from an iPhone. Hold the phone straight above the page, in good light, with the whole sheet in the picture.
Is the text in the PDF searchable?
No. Each page is stored as an image, like a scanner does it. To make the text searchable and copyable, run the finished PDF through OCR PDF, which adds an invisible text layer.
Is the location data of my photos kept?
No. The PDF holds only the new page images, drawn on a canvas and saved again. Camera data stored in the photos, such as the date, the phone model or the GPS location, is not copied into the PDF.