mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-14 19:27:01 -04:00
`embedded_preview_srgb` (the loupe stand-in and the grid thumbnail of an unedited raw) decoded the largest embedded JPEG whatever the size asked for: a 512 px thumbnail of a Sony A7R VI ARW decoded its 9984 x 6656 JPEG (5.6 MB) although the file holds a 1616 x 1080 one (0.3 MB). `lightcraft_raw::embedded_preview_covering(bytes, min_edge)` returns the smallest of a TIFF-based raw's JPEGs whose long edge is at least `min_edge` and that is a copy of the largest one: aspect ratio within 1 % (not a letterboxed thumbnail of another shape) and the same number of components (not the grey semantic masks of an iPhone ProRAW DNG); else the largest, as `embedded_preview`. The colour-space handling stays in `decode_raw_preview` (a `covering` argument); an unsupported raw's editing source and the camera-look fit keep the largest JPEG, so a source never depends on its size level. On 120 raws of every make in the corpus at 256 / 512 / 1600 px: wherever the largest JPEG is still chosen the output is identical byte for byte; where a smaller one is (Sony, Nikon, Panasonic, Adobe DNG) orientation matches, the size is equal or 1-2 px off, mean difference <= 4.7 / 255. - Rebased onto #1020: its plan route (`preview_window` -> `planned_preview`) now takes the box size and picks with `embedded_preview_covering` too, so a TIFF raw read through the sparse plan gets the whole file's JPEG. Co-Authored-By: Claude <[email protected]>