Cover raw and TIFF import in tests and show decode details

The new tests pin the CR2/NEF/CR3/DNG and TIFF routing, container
signatures and TIFF proxy decoding, with an opt-in fixture run for real
raw files. The Info panel now reports the decoder and the proxy size, so
a file that fell back to a camera preview is visible at a glance.
This commit is contained in:
2026-11-28 20:57:53 +00:00
parent 27360ffae7
commit edfc6cdc80
8 changed files with 176 additions and 0 deletions
+12
View File
@@ -2615,10 +2615,22 @@ export function MetadataPanel({
const event = events.find((e) => e.id === photo.eventId);
const [keyword, setKeyword] = useState('');
const [presetId, setPresetId] = useState('');
const decodeLabel = photo.raw
? photo.decode === 'embedded'
? 'LibRaw · camera preview fallback'
: 'LibRaw demosaic'
: photo.decode === 'sharp'
? 'sharp JPEG proxy'
: 'Browser';
const proxyLabel = `${photo.width} × ${photo.height}${
photo.proxyBytes ? ` · ${(photo.proxyBytes / (1024 * 1024)).toFixed(1)} MB` : ''
}`;
const rows: [string, string][] = [
['File', photo.name],
['Dimensions', `${photo.width} × ${photo.height}`],
['Size', `${(photo.size / (1024 * 1024)).toFixed(2)} MB`],
['Decode', decodeLabel],
['Proxy', proxyLabel],
['Camera', photo.meta.camera ?? '—'],
['Lens', photo.meta.lens ?? '—'],
['ISO', photo.meta.iso ? String(photo.meta.iso) : '—'],
+2
View File
@@ -30,6 +30,8 @@ export interface UploadResult {
size?: number;
previewUrl?: string;
thumbUrl?: string;
/** Size of the JPEG proxy the server wrote, when it decoded this file. */
previewBytes?: number;
note?: string | null;
}
+4
View File
@@ -652,6 +652,10 @@ export function normalizePhoto(input: Partial<PhotoRecord> & { id: string }): Ph
typeof input.previewVersion === 'number' && Number.isFinite(input.previewVersion)
? input.previewVersion
: undefined,
proxyBytes:
typeof input.proxyBytes === 'number' && Number.isFinite(input.proxyBytes)
? input.proxyBytes
: undefined,
proofAt: typeof input.proofAt === 'number' && Number.isFinite(input.proofAt) ? input.proofAt : undefined,
name: input.name ?? 'Untitled',
width: input.width ?? 0,
+1
View File
@@ -162,6 +162,7 @@ async function importRaw(
history: [{ label: 'Import', ts: Date.now(), edits }],
raw,
decode: upload.engine,
proxyBytes: upload.previewBytes,
previewUrl,
});
+46
View File
@@ -0,0 +1,46 @@
import { describe, expect, it } from 'vitest';
import {
RAW_ACCEPT,
RAW_EXTENSIONS,
SERVER_IMAGE_EXTENSIONS,
isRawFile,
isTiffFile,
} from './raw';
import { isSupportedFile } from './import';
/** isRawFile/isTiffFile only read the name; isSupportedFile also reads type. */
function fakeFile(name: string, type = ''): File {
return { name, type } as File;
}
describe('import format routing', () => {
it.each(['CR2', 'NEF', 'CR3', 'DNG'])('sends .%s to the server raw decoder', (ext) => {
const file = fakeFile(`IMG_0001.${ext}`, 'application/octet-stream');
expect(RAW_EXTENSIONS.has(ext.toLowerCase())).toBe(true);
expect(isRawFile(file)).toBe(true);
expect(isTiffFile(file)).toBe(false);
expect(isSupportedFile(file)).toBe(true);
});
it.each(['TIF', 'TIFF'])('sends .%s to the server still decoder', (ext) => {
const file = fakeFile(`scan.${ext}`, 'image/tiff');
expect(SERVER_IMAGE_EXTENSIONS.has(ext.toLowerCase())).toBe(true);
expect(isTiffFile(file)).toBe(true);
expect(isRawFile(file)).toBe(false);
expect(isSupportedFile(file)).toBe(true);
});
it('still accepts the browser-decoded formats', () => {
expect(isSupportedFile(fakeFile('photo.jpg', 'image/jpeg'))).toBe(true);
expect(isSupportedFile(fakeFile('photo.png', 'image/png'))).toBe(true);
expect(isSupportedFile(fakeFile('photo.webp', 'image/webp'))).toBe(true);
expect(isSupportedFile(fakeFile('photo.avif', 'image/avif'))).toBe(true);
expect(isSupportedFile(fakeFile('notes.txt', 'text/plain'))).toBe(false);
});
it('offers every supported extension in the file picker', () => {
for (const ext of ['cr2', 'nef', 'cr3', 'dng', 'tif', 'tiff', 'sraw']) {
expect(RAW_ACCEPT.split(',')).toContain(`.${ext}`);
}
});
});
+2
View File
@@ -327,6 +327,8 @@ export interface PhotoRecord {
thumbUrl?: string;
/** Bumped when the stored RAW is re-decoded, to invalidate cached previews. */
previewVersion?: number;
/** Bytes of the server-written editable proxy (raw and TIFF imports). */
proxyBytes?: number;
/** set when this photo was imported from an Immich album */
immich?: { albumId: string; assetId: string; checksum: string };
/** timestamp of the last rendered client proof published to the server */