Skip to content

[12/14] Fixed-size suggested square; settings re-crop processed photos (v1.15.0) - #11

Open
gonzalobravoargentina wants to merge 25 commits into
marinebon:mainfrom
gonzalobravoargentina:stack/12-fixed-square
Open

gonzalobravoargentina wants to merge 25 commits into
marinebon:mainfrom
gonzalobravoargentina:stack/12-fixed-square

Conversation

@gonzalobravoargentina

Copy link
Copy Markdown

Stacked PR — part 12 of 14. Builds on part 11 (stack/11-site-config). GitHub cannot stack PRs across a fork, so until part 11 is merged this PR's diff also shows the earlier parts. Review only this part: gonzalobravoargentina/quadrat-cropper-js@stack/11-site-config...stack/12-fixed-square
Next: part 13 (stack/13-done-notice).

Commits in this part

  • 58e7c04 Fixed-size suggested square; settings re-crop processed photos (v1.15.0)

The camera sits at a fixed height, so the opening has nearly the same px size in every photo of one camera. A % inset still lets tube in when a detection comes out slightly large; the field team wants one fixed square size (e.g. 1500 px in the original photo), centred/rotated on the detected frame, crops exported at the size seen in the viewer, and settings changes applied to photos already loaded.

  • QD.suggestSquare() in qd.js: single geometry helper for app.js and worker.js (best-fit square → inset % or fixed side → inside photo); returns detSide for the batch size check.
  • ⚙ Suggested square: detected − % (default, unchanged) or fixed px; shows the batch's detected openings and suggests a size; flags a fixed square larger than the detected opening.
  • Saving a change re-crops already-processed auto crops from the stored det.quadRaw (worker re-crop mode, no re-detection); manual crops untouched; waits for a running batch.
  • ZIP crop size default → each crop at its own size (median/fixed still available).

Tested on 15 photos + 1 manual: fixed 1500 → 14 auto crops at 1500×1500, manual unchanged; oversize fixed side flagged; back to detected restores the original crops.

Details: §19 of the change guide. Every change is also commented in the code.

Tested: headless Chromium through the real UI against the 16 fixtures (and field samples where noted); npm test could not run in the authoring environment, so CI's run on this PR is the check.

gonzalobravoargentina and others added 25 commits October 30, 2026 16:23
…ing (v1.5.4)

- app: process files added while a batch is running (snapshot loop left them queued)
- app: allow opening the editor on "no frame" (failed) items, as the UI promises
- grid/app: count manually adjusted crops separately from "need manual corners"
- editor: Enter applies; redraw when the same photo is reopened; cache preview pixels
- unzip: decode UTF-8 entry names (accents were replaced with "_")
- export: write UTF-8 names with bit 11 and a valid DOS timestamp
- metadata: strip BOM, sniff ; / tab delimiters, cache CSV index, fix date+code filenames
- docs/review-2026-10-30.md: full list incl. issues not changed here

Static review; npm test not run in the review environment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
…photos

- drive: ingestFolder always returns a Promise (crashed on folders without
  images directly inside); list subfolders recursively (depth 4); skip and
  report individual failed downloads instead of aborting the folder
- editor: failed items open with a centred starting square; Reset falls back
  to it; focus Apply so Enter applies instead of triggering Reset
- docs: review notes updated (marinebon#12-#15)

Verified in headless Chromium with a mocked Google sign-in + Drive API.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
- files.list and downloads pass supportsAllDrives / includeItemsFromAllDrives
  (folders in an organisation Shared drive listed as empty)
- Picker: Shared drives tab + SUPPORT_DRIVES feature
- follow Drive shortcuts to their target folder/file
- detect images by extension too (application/octet-stream, image/JPEG)
- "no images" alert now lists the MIME types that were found

Reported on a real MBON folder after the previous fix; verified in headless
Chromium against a mocked Drive API that enforces the Shared-drive flags.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
…ble from 1.5.4)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
…ual crops (v1.6.0)

- qd.js: export fitSquare (least-squares similarity fit) and fitInside
  (translate, then shrink) — detector core unchanged
- app.js: suggested crop = best-fit square inside the image; flag + cap
  confidence when the detected outline is > 4 % / > 12 % off square, when
  the frame runs off the photo, or when the side is outside 0.8–1.25 x the
  batch-typical size (re-checked when the queue finishes)
- editor: markers clamped inside the photo so they can always be grabbed
- grid/css/index: blue "adjusted" tier for hand-cropped photos + legend
- docs: notes #17-#18 and open items (AP161656 browser failure, 1600 px cap)

Verified in headless Chromium on the 16 repo fixtures.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
… support (v1.7.0)

- worker.js: per-photo pipeline in a Web Worker pool (cores-1, max 8)
- Drive: 4 parallel downloads streamed into the queue with backpressure;
  originals released after processing, re-fetched for the editor
- export: zip assembled from Blob parts (no multi-GB copy in memory)
- suggested square shrunk by a configurable inset (default 5 %, in settings)
- exclude/include toggle on each card; excluded photos listed in manifest
- raw.js: CR2/CR3/NEF/ORF/ARW/DNG/RW2/RAF/PEF/SRW via the largest embedded
  camera JPEG, EXIF + orientation from the RAW, reduced-preview flag
- docs: review notes #19-#22

Verified in headless Chromium: 16 fixtures (same results as sequential),
60-photo mocked Drive folder, real Canon/Nikon RAW samples, synthetic ORF.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
…idy review notes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
- ◀ ▶ + ←/→ with a position counter, without closing the dialog
- dragged markers are applied before moving; photos only passed through
  stay untouched (no default square turned into a manual crop)
- next Drive original prefetched, the one left behind released again

Verified in headless Chromium: local photos (incl. a no-frame one) and a
mocked Drive folder.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
…8.0)

- photos grouped by source folder (Drive path incl. root name, zip folders,
  new "+ Add folder" button and folder drops from Finder/Explorer)
- Metadata tab with presets; first preset = MBON P2P intertidal / CoralNet
  (auto: Name, Date, GPS, Camera; fixed: 42 cm, no strobes, 25x25cm;
  per group: country, state, locality, site, strata list, Photographer,
  Comments, ...); folder names pre-fill state/locality/site/strata
- EXIF reader: GPS, trimmed model strings (TG-6 pads with spaces)
- export: crops named like the source (optional date prefix),
  metadata_coralnet.csv, EXIF (date, GPS, camera, fields) embedded per crop,
  warning when required fields are empty; manifest gets a group column

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
…ed names (v1.8.1)

- folder parser for COUNTRY/YEAR/SEASON/LOCALITY/SITE/STRATA (deepest first,
  ALTO/MEDIO/BAJO -> HIGHTIDE/MIDTIDE/LOWTIDE, FRIO/CALIDO season)
- state + AMP code pre-filled from the 2026 campaign's localities; new
  localities (state, AMP, photographer) learned in this browser
- new `season` field (EXIF + manifest, not a CoralNet column)
- YYYYMMDD_ prefix is the default file-name format

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
…e page (v1.8.2)

- "+ Add photos" menu: a folder with all its subfolders (default), or files/zip;
  clicking the drop area opens the folder picker; CSVs in the folder joined
- progress moved to a small fixed corner card; stats line keeps its height,
  so the grid stays put while photos load
- queued photos shown neutral instead of red

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
- presets get their own folder parser, defaults, remembered fields and
  copy-from fields (Photographer <- Group)
- Azores workshop: Aux Group, country, locality, site, strata; PORTUGAL /
  ILHA TERCEIRA / "Azores Workshop 2026" defaults; Group from Group_N /
  Grupo N / Transect_N folders; CSV header identical to the workshop file

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
…1.9.1)

- dragging a corner rebuilds the square from the diagonal, opposite corner
  fixed; dragging inside the square moves it; never leaves the photo
- checkbox (on by default, remembered) to go back to free corners

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
…TG-7 (v1.10.0)

The mint band (hue 118-172) was tuned on Panasonic G8 photos, where the tube
reads ~144 deg; the protocol camera (Olympus/OM TG-6/TG-7) renders it at
~165-185 (air) and ~180-205 (underwater), so few tube pixels were in band and
many field photos failed. New `cyan` pass (158-205), run only when no earlier
color reached 0.8 -> unchanged results and speed for photos that already work.

Field photos (10 intertidal TG): 4 ok / 2 review / 4 failed -> 9 ok / 1 review.
Repo fixtures: identical results; pre-cropped PB110048/PB110110 still rejected.
Square-check review threshold 4 % -> 6 % (TG openings read ~5 % wider than tall).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
Studied on 125 field samples from 8 cameras (TG-6/TG-7/ORF, Canon D20, Canon
SL1 JPG+CR2, GoPro, iPhone): 85 ok / 10 review / 30 failed -> 104 / 8 / 13.

- openingSideMax 0.75 -> 0.95: TG-7 1:1 subtidal shots fill ~85 % of the
  frame and were all rejected (now 10/10); pre-cropped fixtures still fail
- new `white` color pass for thin white/aluminium rod frames (subtidal
  Canon / GoPro), last resort when nothing reached 0.8
- all 16 fixtures pass; AP161656 (failed in the browser since v1.5.3) now
  detected correctly

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
- crops warped at the opening's native resolution (1600-px cap removed)
- export resamples all crops to one side: batch median (default), a fixed
  px value, or each crop's own size (setting in the gear dialog); same
  25 x 25 cm -> same px/cm across the batch
- manifest.csv: square_side_px and output_px columns

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
docs/CHANGES-1.5.3-to-1.12.0.md explains every change by theme (why /
what / where / how tested), with a version map, file map, settings and
localStorage keys, invariants, manual checks and open points.
AGENTS.md gains the pipeline invariants; README and the original review
log link to the new guide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
…k merge by time (v1.13.0)

- js/maptab.js (new): Leaflet map (vendored 1.9.4, lazy-loaded) with
  Sentinel-2 cloudless (EOX, no key, CC BY-NC-SA), optional Esri World
  Imagery (free ArcGIS key in ⚙) and OpenStreetMap. Markers coloured by
  source; popup with Move / Remove. Photos without a position can be
  ticked and placed with one map click.
- js/geo.js (new, no DOM): GPX/KML/CSV track parsing, camera time → UTC
  (time-zone selector or EXIF OffsetTimeOriginal, SubSecTime), clock offset
  from a photo of the GPS screen (iBenthos method, re-implemented),
  interpolation with max-gap / end tolerance, QDGeo.position(it).
- Positions reach the CoralNet CSV, the crops' EXIF and manifest.csv
  (new latitude, longitude, gps_source columns).
- exif.js reads OffsetTime(Original) and SubSecTimeOriginal.
- exifwrite.js: DMS seconds could round to 60"; now carried in integers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
After switching branches the browser showed the new index.html (Map tab)
with a cached old app.js/qd.js (v1.12.0), so the Map tab did nothing.
tools/serve.py is http.server plus a no-store header.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
New "Download metadata.csv" button (Metadata tab only) so metadata fixed
after a CoralNet upload can be re-downloaded without re-exporting crops.
export.js: crop naming factored into cropNames() and shared by exportZip
and the new metadataCsv(), so Name always matches the ZIP's file names.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
Quadrats ~1 m apart overlapped at the old max zoom (19). Tiles are now
over-zoomed past each layer's native level, so markers stay separable
(~2 cm/px); fit-to-photos stops at z19.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
Esri World Imagery only reaches z17 in parts of Patagonia (e.g. Puerto
Madryn); deeper requests returned grey "no data" tiles. The layer now asks
Esri's tilemap service which level exists at the map centre (cached per
~5 km cell) and over-zooms the deepest real imagery.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
…14.3)

js/site-config.js (empty here) can be overwritten at deploy time so a
hosted copy gives every visitor Esri World Imagery; a key set in ⚙ still
wins. The map opens on Esri when a key exists and no basemap was chosen.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq
- QD.suggestSquare (qd.js): one geometry helper for app.js and worker.js
  (best-fit square → inset % or fixed side in original px → inside photo).
- Settings "Suggested square": detected − % (default) or fixed px; shows the
  batch's detected openings and a suggested size; flags a fixed square
  larger than the detected opening.
- Saving re-crops already-processed auto crops from the stored detection
  (worker re-crop mode, no re-detection); manual crops untouched.
- ZIP crop size default: each crop at its own size.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HJmVbVrogQf2RfdDWi5ELq

This branch has not been deployed

No deployments
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