Skip to content

Photos: NHTSA's own crash-test vehicle photos instead of IMAGIN - #30

Open
keptlive wants to merge 4 commits into
fast-first-reportfrom
nhtsa-photos
Open

keptlive wants to merge 4 commits into
fast-first-reportfrom
nhtsa-photos

Conversation

@keptlive

Copy link
Copy Markdown
Owner

Replaces the IMAGIN.studio photos. Reports were loading them under IMAGIN's customer=demo id, which mcp.vin has no licence for, and they now show an "Access error" image. Reports now show NHTSA's own photos of the vehicle it crash-tested, served from mcp.vin.

Base: fast-first-report (#29, still open). Merge #29 first.

What a report shows

  • Before the test: up to 3 views of the NHTSA test car (front three-quarter, side, rear three-quarter). The first is the main photo; the others are thumbnails.
  • Crash tests: then up to 3 views of the car after each NHTSA crash test of that model year: frontal, side barrier, side pole, rear. Each view is the whole car after the test.
  • Captions: every caption says what the photo shows and names the test car, for example "NHTSA's test car: 2022 Nissan Pathfinder four door SUV. Not this vehicle; trim, colour and equipment may differ." It links NHTSA's report for that test. Crash views also say how the test was run ("A moving barrier was driven into the car's left side at 62 km/h (38 mph).").
  • No match: photos is null and the page has no photo area. /api/vin/:vin/photo answers 302 to the first photo, or a JSON 404 (photos: null).
  • Which car (matching):
    • It uses the same closest-match tiers as test_vehicle_specs, with stricter rules.
    • Never a tested car with another body style, cab or door count.
    • Another model year only when Transport Canada lists the same wheelbase for both years.
    • A photo from before the test is required before anything is shown.

How photos are chosen and built

  • scripts/nhtsa_photo_select.py reads the test lab's file names and fails closed. Labels, dummies, interiors, underbody, close-ups and camera names (IMG_1234) are never used. I checked the rules on contact sheets of 57 tests from all 5 labs, model years 2007 to 2025.
  • scripts/build-nhtsa-photos.py downloaded each photo once on the storage server: one connection, 1 request per second, a generic client name. It stops on 429, 5xx, or three 403s in a row. Each photo becomes a WebP that fits 960x720 (q74) plus a 320x240 thumbnail, with metadata stripped.
  • data-src/test-vehicle-photos.jsonl is the index: 1,840 tests and 7,308 photos. The importer puts it in table photos of data/tire-placards.db and drops any photo whose files are missing.

Coverage

What Result
Crash tests the site can match 2,202
Tests with photos 1,840
Model years 2011-2024 88-99% of tests
Model years 2005-2010 0-38% of tests (labs used camera file names then)
Model year 2025 55% of tests
Model year 2026 0% of tests
1,617 dealer-listing VINs (mostly 2026-2027 models), same tested year only 9%
100 listing VINs from 2016-2025, with the real Transport Canada check 57% (6 exact match, 8 another version of the same year, 43 a nearest year of the same generation)

Model years 2025 and 2026 are low because NHTSA's photo host answered HTTP 502 for the newest tests near the end of the build. 218 photos of 59 tests were left out. The build is resumable.

Deploy (owner only, not done)

  1. Diff the server first: /opt/vin-mcp has uncommitted edits. Then copy the changed files: git diff --name-status fast-first-report..nhtsa-photos. Delete lib/photo.mjs.
  2. Copy the images to the web server. They are on storage at /root/nhtsa-photos/deploy/nhtsa-photos-2026-11-18.tar: 523.7 MB, 1,840 folders, 14,616 WebP files. sha256 a07bfc1f8e42fa8629ed4280a2d3a3292c256f4523e25f087bd096cdc5b7f5e6. Unpack to /opt/vin-mcp/data/nhtsa-photos/, for example by streaming it through the phone:
    ssh root@104.37.188.237 cat /root/nhtsa-photos/deploy/nhtsa-photos-2026-11-18.tar | ssh root@192.210.135.200 'tar -xf - -C /opt/vin-mcp/data'
    The web server has 5.2 GB free (92% used), so this leaves about 4.7 GB.
  3. Run cd /opt/vin-mcp && npm run import:test-vehicles after the folder is in place. Expect photos.rows 1840, photos.photos 7308, photos_dir_verified true, photos_missing_files_left_out 0.
  4. Run systemctl restart vin-mcp. BASE_URL is unset, so URLs use https://mcp.vin, which is correct.
  5. Change the nginx CSP. In /etc/nginx/sites-available/mcp.vin line 55, drop https://cdn.imagin.studio from img-src. The header becomes:
    default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; font-src 'self' https://fonts.gstatic.com; img-src 'self' data:; connect-src 'self'; frame-ancestors 'none'
    Then run nginx -t && systemctl reload nginx. .webp already goes through the static location block to express.
  6. Check:
    • curl -I https://mcp.vin/nhtsa-photos/14086/v14086P014-960.webp answers 200 image/webp.
    • curl -sI https://mcp.vin/api/vin/5N1DR3BD8NC239595/photo answers 302.
    • /1HGCM82633A004352 shows no photo area.

Tests

  • flock /tmp/vin-mcp-test.lock npm test: 277 node tests pass, 1 skipped (data/decode-evidence.db is not built here); all Python suites pass. New tests: tests/nhtsa_photos_test.py (14) and tests/test-photos.test.mjs (7).
  • Headless Chromium at 390 px, light and dark emulation (the site has no dark theme):
    • A car with photos shows the main photo, thumbnails and 3 crash views; a thumbnail click swaps the photo and caption.
    • A car without photos has no photo area.
    • With show_photos off, the area is hidden.
    • The car sheet prints on 1 page in both cases.
    • No console errors, no third-party image requests, no horizontal scroll.

🤖 Generated with Claude Code

root and others added 4 commits November 18, 2026 12:57
Reports showed IMAGIN.studio renders under an unlicensed demo customer id. The
photos block now holds the test lab's photos of the car NHTSA tested (before
the test, then after each crash test of that model year), chosen by file name,
resized to WebP and served by mcp.vin itself.

- scripts/nhtsa_photo_select.py: file-name rules, fail closed
- scripts/nhtsa-photo-manifest.py, scripts/build-nhtsa-photos.py: manifest,
  one-time download and resize on a build server
- scripts/import-tire-placards.py: photos table from
  data-src/test-vehicle-photos.jsonl
- lib/test-photos.mjs + lib/tire-placards.mjs: which tested car (same body,
  cab, doors and generation), crash views per test kind
- /api/vin/:vin/photo redirects to the first photo or answers 404
- site: photo strip with captions naming the test car and test; no photo
  area when there is none; IMAGIN removed from pages, docs and privacy

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- crash views are the whole car after each test (the impact-moment photos
  are mostly 222x127 web thumbnails); unknown struck side gives no view
- newer NHTSA listings name files by the lab's long name: stems vNNNNNNnnn
  from the listing index, URL paths percent-encoded
- tests: file-name rules on real names from five labs (2007-2025), choice
  per test, importer checks, image build stop rules; lookup tiers, shape and
  generation rules, null cases; the page script's URL and caption rules
- /api/vin/:vin/photo answers 404 with photos null when there is no photo

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
data-src/test-vehicle-photos.jsonl is built from the full image build
(511.6 MB of WebP, kept outside git). 218 photos of 59 of the newest tests
are not in it: NHTSA's photo host answered HTTP 502 for them and the build
stopped as designed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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