fix(raw): fix FUJIFILM RAF & RAW color cast by prioritizing pre_mul WB multipliers

This commit is contained in:
2026-10-10 22:22:36 +07:00
parent 61085a1fa2
commit 8b27f9542d
4 changed files with 185 additions and 9 deletions
+11 -8
View File
@@ -558,16 +558,17 @@ export function detectCameraBrand(fileName?: string, meta?: any): CameraBrand {
}
export function getBrandWbMultipliers(brand: CameraBrand, cd: any): number[] {
// 1. Try camera WB multipliers from LibRaw (cam_mul)
if (cd?.cam_mul && Array.isArray(cd.cam_mul) && cd.cam_mul.some((v: number) => v > 0 && v !== 1)) {
return cd.cam_mul;
}
// 2. Try pre-calculated WB multipliers from LibRaw (pre_mul)
// 1. Try pre-calculated WB multipliers from LibRaw (pre_mul)
// LibRaw pre_mul contains green-normalized, daylight-calibrated WB multipliers.
if (cd?.pre_mul && Array.isArray(cd.pre_mul) && cd.pre_mul.some((v: number) => v > 0 && v !== 1)) {
return cd.pre_mul;
}
// 2. Try camera WB multipliers from LibRaw (cam_mul)
if (cd?.cam_mul && Array.isArray(cd.cam_mul) && cd.cam_mul.some((v: number) => v > 0 && v !== 1)) {
return cd.cam_mul;
}
// 3. Brand-calibrated WB fallbacks (prevents generic single fallback from producing color casts)
switch (brand) {
case 'fujifilm':
@@ -658,9 +659,11 @@ function previewIsFrame(preview: Uint8Array, meta: any): boolean {
Number(meta?.iwidth) || 0,
Number(meta?.iheight) || 0,
Number(meta?.width) || 0,
Number(meta?.height) || 0
Number(meta?.height) || 0,
Number(meta?.raw_width) || 0,
Number(meta?.raw_height) || 0
);
if (!size || !frame) return true;
if (!size || !frame) return false;
return Math.max(size.width, size.height) >= frame * 0.9;
}