Skip to content

feat: date-from-ocr workflow, assets ocr, structured search filters - #46

Merged
dhcgn merged 1 commit into
mainfrom
feature/date-from-ocr
Nov 22, 2026
Merged

dhcgn merged 1 commit into
mainfrom
feature/date-from-ocr

Conversation

@dhcgn

@dhcgn dhcgn commented Nov 22, 2026

Copy link
Copy Markdown
Owner

Summary

New: client-workflow date-from-ocr. It sets an asset's capture year from a year that Immich's OCR found in the image, typically on scanned or re-photographed prints.

  • Sources
    • --album-id / --album-name
    • asset IDs or Immich web links, as arguments or via --ids-file
    • --all for the whole library: one server-side OCR search per year, then an OCR check of each hit. Takes about 22 s on a real library.
  • Report by default. Each hit is listed with its web link, also available as --json. Each hit gets a status: change, matches or ambiguous (several years).
  • --yes applies only unambiguous single-asset changes. The date becomes YYYY-06-01 00:00 and the asset is tagged immich-admin-cli/date-from-ocr.
    • Never applied album-wide.
    • Refused together with --all: library-wide hits contain many numbers that are not dates, such as "seit 1938" or "2000 qm".
  • --interactive (needs a terminal) groups the hits by album and offers [s]kip [t]his [a]lbum [n]ext album [y]ear [o]pen [q]uit.
    • [a]lbum lists every asset in the album with its old and new date, then asks again (default No). Assets changed this way are tagged immich-admin-cli/date-from-ocr-album.
    • --all --interactive skips assets whose year already matches.

Also in this PR

  • New assets ocr command (getAssetOcr).
  • Every command that takes asset IDs now also accepts Immich asset links, e.g. …/people/<id>/photos/<assetId>?….
  • Bug fix in search metadata. On current servers every filtered search failed with 400, because --order sent the new orderBy alongside the deprecated flat fields and the server rejects that mix. The command now uses only the structured filter/orderBy shape:
    • Trashed assets stay excluded via trashedAt: {eq: null}, which the generated type cannot express, so it is patched into the JSON.
    • --taken-after / --taken-before now actually filter; before, they were silently ignored.
    • --type and --order are validated against their allowed values.
  • SearchPager no longer sends the deprecated page field together with the new shape.

Test plan

  • go generate ./... && go build ./... && go test ./... && go vet ./... && go fix ./...
  • Unit tests: year extraction, link parsing, interactive flow (album re-confirmation, next album, other year, EOF), search request body including the trash null, and the pager with the new shape.
  • Staging integration tests:
    • Upload → set year → check date and tag → delete.
    • Library-wide OCR year search (read-only).
  • Read-only checks against a 3.4.0 production server:
    • Report and JSON output for two known scans.
    • search metadata filters, trash exclusion and cursor paging.
    • --all report: 2,069 candidates in 22 s.
    • --all --yes is refused.
  • --interactive exercised by a human in a real terminal (in progress by the author).

Not in this PR: the workflows find-no-thumbhash, find-heic-tile-defect, FetchAlbumAssets and FetchTagAssets still use the deprecated flat search fields. They still work, but should move to filter in a follow-up.

🤖 Generated with Claude Code

Add `client-workflow date-from-ocr`, which sets an asset's capture year from
a year Immich's OCR found in the image (e.g. on scanned prints):
- sources: --album-id/--album-name, asset IDs or Immich web links
  (positional or --ids-file), or --all (whole library, pre-filtered
  server-side by one OCR search per year, then an OCR check of each hit)
- report by default (with web links, --json); --yes applies only
  unambiguous single-asset changes (YYYY-06-01, tag
  immich-admin-cli/date-from-ocr) and is refused with --all
- --interactive (terminal only) reviews hits grouped by album:
  [s]kip [t]his [a]lbum [n]ext album [y]ear [o]pen [q]uit; [a]lbum lists
  every album asset with old -> new date and asks again, tagging
  propagated assets immich-admin-cli/date-from-ocr-album

Also:
- new `assets ocr` command (getAssetOcr)
- every command that takes asset IDs now also accepts Immich asset links
- `search metadata` now uses only the structured filter/orderBy shape.
  The deprecated flat fields made every filtered search fail with 400 on
  current servers, because --order sent orderBy alongside them. Trashed
  assets stay excluded (trashedAt eq null), --taken-after/--taken-before
  now actually filter, and --type/--order are validated
- SearchPager never sends the deprecated page field with the new shape

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

Copy link
Copy Markdown

Preview binaries (commit c9f3c82)

Download test executables for this PR (linux/darwin/windows + checksums.txt) from the run's Artifacts section (GitHub login required):
https://github.com/dhcgn/immich-admin-cli/actions/runs/45012137984#artifacts

Or with the CLI: gh run download 45012137984 -n immich-admin-pr-46 -R dhcgn/immich-admin-cli

@dhcgn
dhcgn merged commit 3144540 into main Nov 22, 2026
2 checks passed
@dhcgn
dhcgn deleted the feature/date-from-ocr branch November 22, 2026 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant