I built a new tool: https://tools.simonwillison.net/ocr - it runs OCR against images and PDFs entirely in your browser (no file upload needed) using Tesseract.js and PDF.js

I wrote more about the tool and how I built it (with copious amounts of Claude 3 Opus and a little bit of ChatGPT) here: https://simonwillison.net/2024/Mar/30/ocr-pdfs-images/

OCR PDFs and images directly in your browser

Something I really like about this tool is that the entire thing is 226 lines of combined HTML, CSS and JavaScript (plus the PDF.js and Tesseract.js dependencies, loaded from a CDN)

The code is a little untidy but at 226 lines it honestly doesn't matter https://github.com/simonw/tools/blob/9fb049424f4ec8f8ffb91a59ab7111cad56088fc/ocr.html

tools/ocr.html at 9fb049424f4ec8f8ffb91a59ab7111cad56088fc · simonw/tools

Assorted tools. Contribute to simonw/tools development by creating an account on GitHub.

GitHub

Also neat is that the enabling libraries here - Tesseract.js and PDF.js - are both pretty old at this point:

First commit to Tesseract.js was Jun 26, 2015 https://github.com/naptha/tesseract.js/commit/906ce3cadbffaf5f7317a4418f282c4b78bf8385

First to PDF.js was Apr 25, 2011 https://github.com/mozilla/pdf.js/commit/6dc1770bba7a417ce5664c0305469e5bb7ea76bd

init · naptha/tesseract.js@906ce3c

Pure Javascript OCR for more than 100 Languages 📖🎉🖥 - init · naptha/tesseract.js@906ce3c

GitHub

My other OCR project from yesterday: textract-cli, the thinnest possible CLI wrapper around AWS's Textract API, built out of frustration at how hard that is to use!

https://github.com/simonw/textract-cli

It only works with JPEGs and PNGs up to 5MB in size, reflecting limitations in Textract’s synchronous API - anything more than that has to go to S3 first.

Assuming you’ve configured AWS credentials already, this is all you need to know:

pipx install textract-cli
textract-cli image.jpeg > output.txt

GitHub - simonw/textract-cli: CLI for running files through AWS Textract

CLI for running files through AWS Textract. Contribute to simonw/textract-cli development by creating an account on GitHub.

GitHub

New feature for my browser-based OCR tool: you can now select the Tesseract.js language to use, from a list of 102 options

https://tools.simonwillison.net/ocr

OCR PDFs and images directly in your browser

One tiny extra detail which possibly only I care about: changing the selection in the language select now updates a ?language=x query string, so you can bookmark a language and the back/forward buttons navigate through that selected state

Here's OCR for Welsh, bookmarked: https://tools.simonwillison.net/ocr?language=cym

OCR PDFs and images directly in your browser

Anyone get any documents lying around in Middle Ages French, circa 1400-1600?

Apparently Tesseract / Tesseract.js can handle them, so I'd love to see my tool try!

https://tools.simonwillison.net/ocr?language=frm

OCR PDFs and images directly in your browser

Gargantua. La Vie inestimable du grand Gargantua, père de Pantagruel , jadis composée par l'abstracteur de quinte essence. Livre plein de pantagruélisme

Gargantua. La Vie inestimable du grand Gargantua, père de Pantagruel , jadis composée par l'abstracteur de quinte essence. Livre plein de pantagruélisme -- 1535 -- livre

Gallica