Speed up raw imports and add a per-import 16-bit toggle

Import raws four at a time to match the decoder pool, compress the 16-bit
sidecar with RLE on the libuv pool, and demosaic X-Trans files in a single
Markesteijn pass so Fuji imports no longer queue into decode timeouts. The
import dialog now offers 16-bit (default) or 8-bit per import, sent as
`?sidecar=0`, and the camera thumbnail and embedded-preview fallbacks no
longer drop to 8-bit samples or store a 0x0 photo.
This commit is contained in:
2026-12-02 03:25:53 +00:00
parent ea7b5b846c
commit fa0a7e64ef
11 changed files with 464 additions and 101 deletions
+14
View File
@@ -1,3 +1,4 @@
import sharp from 'sharp';
import { describe, expect, it } from 'vitest';
import { cameraThumb16, encodePng16, png16Matrix, resizeRgb16 } from './imaging.mjs';
@@ -75,6 +76,19 @@ describe('cameraThumb16', () => {
expect(out[25]).toBe(2); // colour type RGB
});
it('keeps the full 16-bit samples, not just their high bytes', async () => {
// sharp's raw output is 8-bit unless the pipeline is asked for rgb16, and a
// downconverted thumbnail decodes to 7/15/23 instead of 2000/4000/6000.
const source = encodePng16(flat16(4, 2, [2000, 4000, 6000]), 4, 2, MATRIX);
const out = await cameraThumb16(source, 2, 1);
const { data } = await sharp(out)
.toColourspace('rgb16')
.raw({ depth: 'ushort' })
.toBuffer({ resolveWithObject: true });
const samples = [0, 2, 4].map((at) => data.readUInt16LE(at));
expect(samples).toEqual([2000, 4000, 6000]);
});
it('keeps the camera matrix so the client can convert the samples', async () => {
const source = encodePng16(flat16(4, 2, [1000, 2000, 3000]), 4, 2, MATRIX);
const out = await cameraThumb16(source, 2, 1);