扫描成 PDF
拍摄一份文档,得到读起来像扫描件的东西。
这款工具完全在你的浏览器中运行。文件从不上传,你可以在浏览器的网络标签中亲自验证这一点。 亲自验证:打开浏览器的网络标签观察。你会看到一个查询你是否还有剩余任务的小请求,只包含工具名称和一段哈希,绝不会包含文件。
这款工具的作用
Most people do not own a scanner and everybody owns a camera, but a photograph of a page is not a scan. This closes that gap in four steps: the page is found in the frame, the perspective is flattened, the text is straightened, and the image is thresholded so it reads as a document rather than as a picture of one. On a phone the camera panel captures directly; on a desktop it falls back to the file picker, because most people there are dropping photos they already took.
Use it when something has to be submitted as a scan and there is no scanner in the building: an identity document or a certificate for an application, a signed page going back to an office, a receipt for an expenses claim, or a handwritten note that has to be filed with everything else.
工作原理
- Take the photo here, or drop photos you have already taken. Up to 100 at a time, each up to 100 MB, and every photo becomes one page in the order they are listed.
- Leave find the page and straighten on. A detection the tool is not confident about is discarded rather than guessed at, and the whole frame is used instead.
- Choose the mode. Black and white is the default and is what makes a photograph look like a scan; grayscale suits a page with photographs on it; colour keeps a stamp or a signature in its own ink.
- Pick the page size. A4 or Letter puts every photo on a standard sheet; Match makes each page the shape of its own photo.
- Turn on the searchable-text option if you will need to find or copy words later, and pick the language.
- Press Scan. The pages are assembled into a single PDF and the download starts.
The four steps run in that order because each depends on the one before. The document is a bright quadrilateral somewhere in a frame that also contains a desk, so its outline is detected first. A homography then maps that trapezoid back to a rectangle, which is what removes the leaning look of a photo taken at an angle. Only then is the residual rotation measured, and it is measured from the text lines rather than the page edges, because lines of text give away the true angle more reliably than a torn or shadowed edge does.
Thresholding is the step that decides whether the result is usable. A photograph has uneven lighting, so a single global threshold turns one half of the page black and blows the other half out. An adaptive threshold compares each pixel to its own neighbourhood instead, which is why a phone photo comes out looking like a scan rather than like a photocopy of a shadow. It is also why black and white is the default rather than an option for the brave.
The mode chooses the encoding as well as the look, and that is where the file size goes. A thresholded page is two colours and compresses to almost nothing as PNG, while JPEG would put ringing artefacts around every letter. A grayscale or colour page is photographic and is the other way round, so those are written as JPEG at quality 0.85. A black-and-white scan is routinely several times smaller than the same page in colour.
Resolution is set in dpi and defaults to 200, which is enough for ordinary printed text. Raise it to 300 for small print, faint carbon copies or anything the recognition is struggling with. 400 stores four times the pixels of 200 and rarely reveals something the threshold at 200 had not already found, so it is worth checking one page before committing a hundred. EXIF orientation is read and applied before any of the geometry, so a photo your phone tagged sideways is not straightened into the wrong rectangle.
Recognition, when you switch it on, runs on the processed pages rather than the originals - that is the whole point of doing the image work first, because a straightened, thresholded page recognises far better than a photograph of one. The words are placed as an invisible text layer over the image, so the page looks exactly as it did and the text can be selected, searched and copied. Words the recogniser scored below 40 per cent are left out rather than added wrong, since a wrong word in a searchable document is worse than a missing one.
这款工具做不到的事
- Page detection can fail on a low-contrast background, a page that runs off the edge of the frame, or a heavily shadowed edge. It then falls back to the whole frame and says so rather than cropping to the wrong rectangle.
- Adaptive thresholding handles uneven light, not every kind of bad light. Hard glare, a strong reflection off glossy paper or a deep shadow across the text will still be visible in the result.
- Capturing directly needs a camera the browser can reach and your permission to use it. On a device without one, the tool falls back to the file picker and works on photos taken elsewhere.
常见问题
- 我可以在这里拍照,还是需要已经有一张照片?
- 两种都行。在手机或平板上,摄像头面板会在页面中打开,实时显示检测到的纸张轮廓,并直接拍进队列。在桌面设备上,或任何浏览器无法访问摄像头的地方,它会回退到文件选择器,让你可以拖入用别的设备拍的照片。之后的处理无论哪种方式都完全相同。
- 我怎样才能得到看起来像真扫描的结果?
- 把纸放平,让它占据画面的大部分,并把四个角都保持在画面之内,好让轮廓能被找到。均匀的间接光胜过明亮的台灯,后者会投下二值化无法去除的硬阴影边缘。避免让你自己的影子落在纸上,并让摄像头大致与纸面平行——透视校正能处理倾斜,但倾斜越小,需要拉伸的就越少。
- 它裁错了区域,或者根本没裁剪。现在怎么办?
- 工具没有把握的检测会被有意丢弃,因为错误的自动裁剪比不裁剪更糟:这时会改用整个画面,并且结果会告诉你有多少页被裁剪了。如果某一页被裁错了,就换一个与纸张形成对比的背景重拍。如果你已经在别处裁剪过照片,就把「找到纸张」整个关掉。
- PDF 生成得很大。我该改什么?
- 先看模式:黑白是作为双色图像的 PNG 写入的,比同一页的彩色或灰度小得多。再看分辨率:200 dpi 对普通文字已经足够,400 存储的像素是它的四倍。如果这之后还是太大,就把结果用「压缩 PDF」处理一遍。
- 之后我能搜索文字吗?
- 可以,只要你在转换前开启文字识别。可选英语、印度尼西亚语,或两者一起。识别出的词会作为一层不可见的图层写在页面图像之上,所以文档看起来没有变化,但它的文字可以被选中、搜索和复制。置信度低于 40% 的词会被略去,而不是去猜。
- 我的照片会被上传吗,尤其是在开启文字识别时?
- 不会,而文字识别正是最容易在这一点上出错的情形。图像处理在你浏览器内的 Web Worker 中运行,而识别器的 WebAssembly 核心和语言数据来自本站点自己的源,而不是公共 CDN——英语约 10.9 MB,印度尼西亚语约 3.8 MB,首次运行后即缓存。你护照的照片绝不会离开设备。