Repository navigation
Read barcodes from a photo or screenshot, for computers without a camera - #13
Draft
Oliver-Johnson wants to merge 4 commits into
Draft
Oliver-Johnson wants to merge 4 commits into
Oliver-Johnson wants to merge 4 commits into
Conversation
Desktops rarely have a camera, so the Scan tab and a recipe's Scan ingredient dialog get a "Barcode from Image" button. On a computer a photo can also be dropped onto Log Food or a screenshot pasted. The image is decoded with the native BarcodeDetector where the browser has one, else ZXing at a few sizes and angles; slower tryHarder reads must agree across two passes, which stops blurry codes being misread as another product. A barcode number typed into Search (valid GTIN check digit) is looked up directly and shown first. With no camera, the Scan tab hides the empty viewfinder and points to the image option instead of a permissions error. Adds a smoke test with a photo fixture; CI installs @zxing/library so the test can serve it locally. Version 2026-10-07.3, docs updated. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017wFUsVAFFzEVnLmxe6TiLk
5 tasks done
The new smoke test timed out on all three WebKit devices in CI while passing on Chromium. WebKit can expose BarcodeDetector without a working backend, and detect() never settling would leave the image scan stuck. Only use the native detector for formats it reports, and give up on it after 3 seconds and fall back to ZXing. The test now reports the scan status if the sheet doesn't open. Version 2026-10-07.4. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017wFUsVAFFzEVnLmxe6TiLk
With the status now reported, the WebKit failure reads "Couldn't open that image": Playwright's WebKit routes blob: URLs (it only skips data: and about:), and a blob URL has no hostname, so the block-everything- external route aborted the photo's object URL. Only http(s) requests are checked now. Real browsers were never affected. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017wFUsVAFFzEVnLmxe6TiLk
Log Food opens on Search on desktop once the desktop pages land (#11/#12), which hides the Barcode from Image button. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017wFUsVAFFzEVnLmxe6TiLk
5 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Oliver · project thread
Checks
index.htmlorsw.jswithout understanding the PWA cache implications (no new cached assets; the reader is the ZXing script the camera scan already loads)index.htmlhas been bumped (Version 2026-10-07.4, matchingsw.js)manifest.jsonis still valid JSON (unchanged)What this changes
Before: the only way to scan a barcode was a live camera. On a laptop or desktop with no camera, the Scan tab showed an empty black viewfinder and a "check permissions" error, and typing the barcode number into Search found nothing.
After: the Scan tab and a recipe's Scan ingredient dialog have a Barcode from Image button. Pick a phone photo or a screenshot and the product opens exactly as if it had been scanned. On a computer you can also drag a photo onto Log Food or paste a screenshot (Ctrl/Cmd+V), from any Log Food tab. Typing the number under a barcode into Search now shows that product first, tagged Barcode. With no camera, the empty viewfinder is hidden and the status says to use Barcode from Image.
How: the image is decoded with the browser's
BarcodeDetectorwhere it works (Android, macOS and ChromeOS Chrome; only for formats it reports, and abandoned after 3 s so a broken implementation can't stall the scan), otherwise with ZXing at a few sizes (up to 3000px, so small barcodes in 4K photos still read) and at 0° and 45°. Quick passes run first; ZXing's slowerTRY_HARDERmode catches sideways and blurry codes, but in testing it sometimes misread them as a different valid barcode, so its reads must agree across two passes (or be the only read) before they are looked up. Typed numbers are only looked up when the GTIN check digit is valid, so partial numbers don't trigger lookups.Files:
index.html(feature),sw.js(version), docs What's New, changelog and the barcode scanner guide (new "No camera?" chapter), a smoke test with a photo fixture, and CI installs@zxing/library@0.23.0next to Playwright so that test can serve the reader locally (all other network stays blocked).Testing done
blob:URL, because Playwright's WebKit routes blob URLs (it only skipsdata:andabout:, seewkPage.js) and a blob URL has no hostname. The route now only checks http(s). Test-only; real browsers were never affected.Notes for reviewer
Draft until you've tried it on beta: the same change is merged into beta in #14. The Log Food layout PR (#11) uses v2026-10-07.3 and also touches the Scan tab, so if this merges first, #11 needs a version bump.
🤖 Generated with Claude Code
https://claude.ai/code/session_017wFUsVAFFzEVnLmxe6TiLk