Skip to content

Thumbnails: camera RAW, a checked cache, clearer misses - #17

Closed
thisisgm wants to merge 8 commits into
omacom:mainfrom
thisisgm:thumbnails
Closed

thisisgm wants to merge 8 commits into
omacom:mainfrom
thisisgm:thumbnails

Conversation

@thisisgm

@thisisgm thisisgm commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Six changes to thumbnails, one commit each with its own tests: camera RAW files show their picture without a RAW thumbnailer, a cached thumbnail has to belong to its file, a failure is tried again once Folio can draw more, a thumbnailer is found through a type's aliases, a type nothing installed can draw says which package would, and a thumbnailer installed later draws what failed before. Two smaller commits on top answer review: a RAW preview is turned by its own directory's orientation, and no package is named for a PDF that pdftoppm draws. The suite goes from 188 to 199 tests. No library is linked in and nothing new is needed to run.

What you'd notice

  • Camera RAW files show their picture. Most RAW files were a blank tile unless a RAW thumbnailer was installed. The camera stores a finished JPEG inside each file, and a bounded reader of the TIFF directories now finds the largest one in a CR2, NEF, NRW, ARW, SR2, DNG or PEF, so nothing is decoded from the sensor data and nothing is linked in. A preview that does not decode is passed over for the next largest, all within one read limit. A preview is turned by the orientation its own directory names, and by the file's when it names none. An installed thumbnailer still answers first, and a broken file is refused rather than guessed at (offsets, counts and lengths are checked against named limits). CR3, RAF, ORF, RW2 and SRW keep their JPEG in other containers and still show an icon.
  • A thumbnail made for another file is not shown as this one's. A cache entry or failure marker was trusted on its modified time alone. It now also has to carry this file's Thumb::URI, as the thumbnail spec asks a reader to check; otherwise the thumbnail is made again.
  • A file that failed once gets another try once Folio can draw it. Failure markers went to fail/folio, so a file one release could not thumbnail stayed blank under every later one, as camera RAW would here. They now go to the spec's fail/<program>-<version>, as fail/folio-2: the number is raised whenever Folio learns to draw more.
  • A thumbnailer that names a type by an alias is used. Folio asks with the canonical name, so a thumbnailer that declares only an alias never matched: glycin declares image/x-dds and the file is image/vnd.ms-dds. Declared types are resolved to canonical names once, when the thumbnailers are read. On a stock Omarchy install 23 of the 196 declared names are aliases, and DDS pictures and WAV audio gain the thumbnailer they already had.
  • A thumbnailer installed later gets its turn. A file nothing installed could draw kept its failure marker, so installing the thumbnailer for its type changed nothing until the file or Folio did. The marker now records the thumbnailer command the type had when it failed, none included, and holds the file back only while that is the same. A thumbnailer that failed is still run once.
  • A missing thumbnailer has a name. A type with no installed thumbnailer showed an empty preview and nothing else. The details pane now says which optional package draws it, from the types ffmpegthumbnailer, papers, glycin and libgsf declare. A PDF names none where pdftoppm is there to draw it.

Numbers

Measured on a mini PC with no RAW thumbnailer installed, cold start, main against this branch. Both tables are from the branch as it stands on the CMake build.

A folder of 100 RAW files in twelve formats, three runs each:

main this branch
Files with a picture 26 56
Failure markers written 40 10
Thumbnails finished after 1154 to 1273 ms 1148 to 1441 ms

The rest of Folio pays nothing for it. Time until the window is up and the process has gone quiet, six runs a view:

View main this branch
Grid, 100,000 files 3989 to 4083 ms, 235.8 to 236.6 MiB 4012 to 4167 ms, 235.9 to 236.6 MiB
List, 100,000 files 3788 to 4234 ms, 183.9 to 197.8 MiB 3868 to 4426 ms, 183.9 to 197.7 MiB
Columns, 100,000 files 5131 to 5493 ms, 195.7 to 207.8 MiB 3850 to 5448 ms, 195.5 to 213.8 MiB
Grid, 2,000 pictures and videos 4446 to 4627 ms, 153.6 to 154.2 MiB 4522 to 5081 ms, 152.7 to 155.3 MiB

The ranges overlap in every view, and the media folder draws the same 105 thumbnails on both.

Screenshots

One RAW file from each of twelve cameras, main above and this branch below: Nikon, Pentax and Sony gain their picture.

Camera RAW tiles before and after

A cache entry written for another file (the first tile, which should be red) and one that names no file (the third, flipped so it shows), each with a matching modified time, main on the left and this branch on the right:

Stale cache entries before and after

The details pane for a video with ffmpegthumbnailer not installed, before and after:

Missing package before and after

Tests

Eleven new cases, each failing without its commit: a cache entry and a failure marker for another file are rejected; a failure an older Folio remembered is tried again, once; an alias finds its thumbnailer; a RAW file's embedded JPEG is shown, the largest of several is picked, a smaller one is shown when the largest does not decode or does not fit the read limit, a broken file is refused, and an installed thumbnailer still wins; the pane names the package for a type; a file that failed with nothing installed is drawn once a thumbnailer for it is. The two commits on top extend two of them: a later directory's own orientation rules its preview, and a PDF's package is named only without pdftoppm. Every commit builds and passes the suite on its own, also with a temp folder whose name has a space.

@greptile-apps

greptile-apps Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issues remain from this review.

Summary

Adds embedded JPEG thumbnails for supported camera RAW files and checks that cached thumbnails belong to their files.

  • Supported camera RAW files show their embedded picture.
  • Cached thumbnails only match the file they name.
  • Failed files get another try when thumbnail support changes.
  • Thumbnailers match files named by MIME aliases.
  • The details pane names a package for some missing previews.

Reviews (12) · Last reviewed commit: "Name no package for a PDF that pdftoppm ..." · Reviewed by Greptile

Comment thread src/rawembed.cpp Resolved
Comment thread src/thumbnails.cpp Resolved
@thisisgm
thisisgm force-pushed the thumbnails branch 3 times, most recently from 9e86482 to 182dbff Compare November 11, 2026 14:19
@thisisgm
thisisgm force-pushed the thumbnails branch 2 times, most recently from c23f80b to bf4a85d Compare November 11, 2026 16:02
A cache entry or failure marker was trusted on its modified time alone,
so one made for another file with the same time was shown as this
file's. It now has to carry this file's Thumb::URI as well, as the
thumbnail spec asks a reader to check.
@thisisgm
thisisgm force-pushed the thumbnails branch 2 times, most recently from 311e0c0 to bb0f83c Compare November 11, 2026 16:55
Failure markers went to fail/folio, so a file Folio could not
thumbnail stayed blank after it learned to, as it does for camera RAW
here. They now go to the spec's fail/<program>-<version>, as
fail/folio-2: the number is raised whenever Folio learns to draw more.
A thumbnailer that names a type only by an alias never matched the
canonical name Folio asks with, so glycin's image/x-dds left a DDS
file blank. The declared types are resolved to canonical names once,
when the thumbnailers are read.
A CR2, NEF, NRW, ARW, SR2, DNG or PEF showed a blank tile unless a RAW
thumbnailer was installed. The camera stores a finished JPEG in each,
and a bounded reader of the TIFF directories now finds the largest
one. An installed thumbnailer still answers first.
A type with no installed thumbnailer showed a blank tile and nothing
else. The details pane now says which optional package draws it, from
the types ffmpegthumbnailer, papers, glycin and libgsf declare.
A file nothing installed could draw kept its failure marker, so a
thumbnailer installed afterwards never ran for it. The marker now
records the thumbnailer the type had, none included, and holds the
file back only while that is unchanged.
One orientation was kept for the whole file, so a preview whose
directory names a turn of its own was turned by IFD0's instead. Each
embedded JPEG now carries its directory's orientation, and takes the
file's only when its directory names none.
With Poppler installed and no PDF thumbnailer, a PDF that failed to
draw (damaged, or locked with a password) had the details pane name
papers as missing. A PDF's package is now named only when pdftoppm is
not there either.
@dhh

dhh commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Thank you, @thisisgm, this is lovely work. To land it without waiting on pushes to your fork, it's continued in #66 from a branch here, with your commits kept exactly as you made them and you credited at the top. The review fixes are added as commits on top: the embedded JPEG's orientation is read past fill bytes and from IFD0 only, the cleanup of old failure markers never follows a link out of the cache, and a RAW claiming an impossible size is skipped before decoding. Closing this one in favour of #66.

@dhh dhh closed this Nov 11, 2026
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