From 842874ee5e01559db6b82b71a7d7a7319fd947e8 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 7 Oct 2026 09:22:28 +0000 Subject: [PATCH 1/4] Read barcodes from photos, screenshots and typed numbers 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) Claude-Session: https://claude.ai/code/session_017wFUsVAFFzEVnLmxe6TiLk --- .github/workflows/test.yml | 5 +- CONTRIBUTING.md | 2 +- docs/barcode-scanner.html | 41 ++++-- docs/changelog.html | 29 +++- docs/index.html | 27 +++- index.html | 220 +++++++++++++++++++++++++++++-- sw.js | 4 +- tests/fixtures/barcode-photo.jpg | Bin 0 -> 104295 bytes tests/playwright.config.js | 2 +- tests/smoke.spec.js | 37 ++++++ 10 files changed, 333 insertions(+), 34 deletions(-) create mode 100644 tests/fixtures/barcode-photo.jpg diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 293311c..d209af9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -16,9 +16,10 @@ jobs: with: node-version: 22 - # The app has no package.json; install the test runner without creating one. + # The app has no package.json; install the test runner (and the barcode reader + # the photo-scan test serves locally) without creating one. - name: Install Playwright - run: npm install --no-save playwright@1.56.1 + run: npm install --no-save playwright@1.56.1 @zxing/library@0.23.0 - name: Install browsers run: npx playwright install --with-deps chromium webkit diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index df6f0c5..eae0b7f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -22,7 +22,7 @@ The smoke tests in `tests/` drive the app in Playwright on Android, iPhone, iPad and desktop sizes. To run them locally in Chromium: ```bash -npm install --no-save playwright@1.56.1 && npx playwright install chromium +npm install --no-save playwright@1.56.1 @zxing/library@0.23.0 && npx playwright install chromium MT_BROWSERS=chromium npx playwright test -c tests/playwright.config.js ``` diff --git a/docs/barcode-scanner.html b/docs/barcode-scanner.html index dd8d690..83414b5 100644 --- a/docs/barcode-scanner.html +++ b/docs/barcode-scanner.html @@ -425,7 +425,7 @@

Feature Guide

Barcode Scanner

- Point your camera at a product barcode and Macrolog looks it up instantly. Results are cached, so foods you scan often appear in a flash. + Point your camera at a product barcode, or give Macrolog a photo of one, and it looks the product up instantly. Results are cached, so foods you scan often appear in a flash.

@@ -451,37 +451,60 @@

How scanning works.

- +
+
+

No camera? Use a photo.

+

+ Most laptops and desktops don’t have a camera you can point at a packet. Take a photo with your phone, or screenshot a barcode from a shopping site, and Macrolog reads the barcode from the image instead. +

+
    +
  • On the Scan tab, tap Barcode from Image and pick the photo.
  • +
  • On a computer, drag the photo onto the Log Food page, or copy a screenshot and paste it (Ctrl+V, or Cmd+V on a Mac).
  • +
  • Recipes work the same way: in an ingredient’s Scan dialog, use Barcode from Image or drop or paste the photo.
  • +
  • Sideways, upside-down and tilted barcodes are fine. A full-size phone photo works even when the barcode is small in it; a blurry one may not.
  • +
  • If a photo won’t read, type the number under the barcode into Search. The product comes up first, marked Barcode.
  • +
+
+
+
+ + +
+
+
-

Scanning tips.

+

Scanning tips.

A clean, steady read is everything. If a code won’t catch, these adjustments almost always fix it.

  • Hold steady — the scanner needs a sharp, well-lit barcode.
  • Move closer or further if it doesn’t detect — 15–25cm is usually ideal.
  • -
  • If the barcode won’t scan, try “Upload Label” or “Paste Text” instead.
  • +
  • If the barcode won’t scan, try “Barcode from Image”, “Upload Label” or “Paste Text” instead.
- -
+ +
-

Product not found?

+

Product not found?

Not every product is in the database yet — but a barcode you add once is yours forever, and instant on every future scan.

diff --git a/docs/changelog.html b/docs/changelog.html index d7677da..f75b689 100644 --- a/docs/changelog.html +++ b/docs/changelog.html @@ -224,14 +224,39 @@

Macrolog

Changelog

A history of every update to Macrolog.

- +
- v2026-10-07.2 + v2026-10-07.3 7 October 2026 Latest
+
+
+
New
+
    +
  • Barcode from Image — on the Scan tab, and in a recipe's Scan ingredient dialog, pick a photo or screenshot and Macrolog reads the barcode from it, then looks the product up as if you had scanned it. Handles sideways, upside-down and tilted barcodes, and small barcodes in full-size phone photos
  • +
  • Drop or paste a barcode image — on a computer, drag a photo onto the Log Food page or paste a screenshot (Ctrl/Cmd+V) to read its barcode, from any Log Food tab
  • +
  • Type a barcode into Search — the 8 to 14 digit number printed under a barcode now finds that product directly, shown first with a Barcode tag
  • +
+
+
+
Improved
+
    +
  • No camera — on a device without a camera the Scan tab no longer shows an empty viewfinder and a permissions error. It says no camera was found and points to Barcode from Image
  • +
+
+
+
+ + +
+
+
+ v2026-10-07.2 + 7 October 2026 +
New
diff --git a/docs/index.html b/docs/index.html index 6a2966f..63faa0a 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1230,14 +1230,14 @@

-
v2026-10-07.2 · 7 Oct 2026
+
v2026-10-07.3 · 7 Oct 2026

The latest update.

- Every release is driven by real use. This one gives laptops and desktops a layout of their own, keeps your custom foods list to foods you added, makes the chart dates readable again, and helps new users set their own targets. + Every release is driven by real use. This one reads barcodes from photos and screenshots for computers without a camera, gives laptops and desktops a layout of their own, keeps your custom foods list to foods you added, makes the chart dates readable again, and helps new users set their own targets.

@@ -1246,6 +1246,27 @@

+
+ + +

Scan a barcode without a camera

+ +

+ Tap Barcode from Image on the Scan tab and pick a photo or screenshot, and Macrolog reads the barcode and looks the product up. On a computer you can also drag a photo onto Log Food or paste a screenshot. +

+ +
+

+ It works in a recipe's Scan ingredient dialog too. If a photo won't read, type the number printed under the barcode into Search and the product comes up first. +

+
+
+
+ +
You can also drop or paste a photo or screenshot of a barcode anywhere on this page.
@@ -1270,7 +1276,7 @@ ▶