Apply a camera profile to every raw from the same camera body

A DCP matrix describes the sensor, so a profile chosen for one frame belongs to
all camera-native raws from that body; the panel offers the bulk apply when the
library holds more photos than the one on screen.

🤖 Generated with Codebuff
Co-Authored-By: Codebuff <noreply@codebuff.com>
This commit is contained in:
2026-11-28 05:49:47 +00:00
parent 749047ae9e
commit d4cce4e001
4 changed files with 100 additions and 1 deletions
+14
View File
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest';
import {
loadSavedCameraProfiles,
photosForCamera,
removeCameraProfile,
saveCameraProfile,
savedProfilesForCamera,
@@ -50,6 +51,19 @@ describe('camera profile library', () => {
expect(loadSavedCameraProfiles(store)).toHaveLength(0);
});
it('collects the camera-native raws of one body for a bulk apply', () => {
const photos = [
{ id: 'a', raw: true, decode: 'libraw', meta: { camera: 'NIKON CORPORATION D700' } },
{ id: 'b', raw: true, decode: 'libraw', meta: { camera: 'Nikon D700' } },
{ id: 'c', raw: true, decode: 'embedded', meta: { camera: 'Nikon D700' } },
{ id: 'd', raw: false, meta: { camera: 'Nikon D700' } },
{ id: 'e', raw: true, decode: 'libraw', deletedAt: 1, meta: { camera: 'Nikon D700' } },
{ id: 'f', raw: true, decode: 'libraw', meta: { camera: 'Canon EOS 5D' } },
];
expect(photosForCamera(photos, 'Nikon D700').map((photo) => photo.id)).toEqual(['a', 'b']);
expect(photosForCamera(photos, '')).toHaveLength(0);
});
it('refuses a matrix that is not nine finite numbers', () => {
const store = memoryStore();
const saved = saveCameraProfile({ name: 'Bad', camera: 'Nikon D700', matrix: [1, 2, 3] }, store);
+29
View File
@@ -114,6 +114,35 @@ export function removeCameraProfile(
return next;
}
/** Minimal photo shape needed to pick the raws of one body. */
export interface CameraProfileTarget {
id: string;
raw?: boolean;
decode?: string;
deletedAt?: number;
meta?: { camera?: string };
}
/**
* Every live camera-native raw from the same body, including the one on screen.
* A JPEG, or a raw the server decoded straight to sRGB, already has its colour
* baked in, so a camera profile has nothing to act on there.
*/
export function photosForCamera<T extends CameraProfileTarget>(
photos: T[],
camera?: string,
): T[] {
const key = cameraKey(camera);
if (!key) return [];
return photos.filter(
(photo) =>
photo.raw &&
photo.decode !== 'embedded' &&
!photo.deletedAt &&
cameraKey(photo.meta?.camera) === key,
);
}
/** Profiles that belong to this body, most recently saved first. */
export function savedProfilesForCamera(
profiles: SavedCameraProfile[],