Skip to content

Read EXIF with a parser somebody maintains - #442

Merged
vikramsoni2 merged 1 commit into
nxzai:mainfrom
cerede2000:p3-10
Sep 26, 2026
Merged

vikramsoni2 merged 1 commit into
nxzai:mainfrom
cerede2000:p3-10

Conversation

@cerede2000

Copy link
Copy Markdown

P3-10 of phase 3 (see #373). Stacked on #433–#441.

exifr was last published in 2022

It is the one dependency in the image whose job is to open a file somebody else wrote,
using code nobody maintains any more — and the metadata route loads it lazily, in a
try/catch, which reads like somebody was not sure of it either:

let exifr = null;
// Optional: try to require exifr only when route is hit

exif-reader replaces it: maintained alongside sharp, and it does nothing but walk a
TIFF-shaped block with a bounds check on every read. The block needs no file access of its
own — sharp already opens the image to report its dimensions and hands the raw EXIF block
back with them — so a photograph's details come from one pass instead of two, and exifr
leaves backend/package.json.

What the block is read for

utils/exifDetails.js: when the picture was taken, the camera and lens, the exposure, the
orientation, the place. Its own file because the metadata route is about what kind of
thing a file is, and this is about what a photograph says of itself.

Checks

  • exif-details.test.js, 20 tests over the reading itself: a block that is not EXIF,
    a truncated one, dates in the three shapes cameras write them, a rational that divides
    by zero, coordinates in both hemispheres. Making the reader answer nothing turns six
    of them red.
  • metadata.test.js, 13 tests through the route.
  • Whole backend suite: 2 509 passed, 2 failed — the two that fail on main alone.
  • Formatting unchanged; frontend builds; backend loads with exifr gone.

capabilities.js, documentText.js and pdfTextExtract.js were in this batch at first
and are not any more: probing which optional tools the machine has, and reading a
document's text, are their own ground, and bringing them here turned three of main's own
tests red.

`exifr` was last published in 2022. It is the one thing in the image that opens a file
somebody else wrote using code nobody maintains any more, and it is loaded lazily in the
metadata route precisely because nobody was sure of it.

`exif-reader` replaces it: maintained alongside sharp, and it does nothing but walk a
TIFF-shaped block with a bounds check on every read. The block itself needs no file
access — sharp already opens the image to report its dimensions and hands the raw EXIF
block back with them — so a photograph's details now come from one pass instead of two,
and `exifr` leaves the dependencies.

`utils/exifDetails.js` holds what the block is read for: when the picture was taken, the
camera and lens, the exposure, the orientation, the place. Written as its own file because
the metadata route is about what kind of thing a file is, and this is about what a
photograph says of itself.

## Checks

`exif-details.test.js`, 20 tests over the reading itself — a block that is not EXIF, a
truncated one, dates in the three shapes cameras write them, a rational that divides by
zero, coordinates in both hemispheres. Making the reader answer nothing turns six of them
red.

`metadata.test.js`, 13 tests through the route.

Whole backend suite: 2 509 passed, 2 failed — the two that fail on `main` on its own.

`capabilities.js`, `documentText.js` and `pdfTextExtract.js` were in this batch at first
and are not any more: probing which optional tools the machine has, and reading a
document's text, are their own ground, and bringing them here turned three of `main`'s own
tests red.
cerede2000 pushed a commit to cerede2000/NextExplorer that referenced this pull request Sep 26, 2026
The batch is reversed, so its findings move from PORT to DONE in the same commit that
sends them. What is left to reverse is whatever `scripts/parity.mjs` still reports.
@vikramsoni2
vikramsoni2 merged commit bc81b4c into nxzai:main Sep 26, 2026
1 check passed
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.

2 participants