fix: sync frontend preset multipliers and fix sharpen type error

Add clahe and normalise entries to frontend PRESET_MULTIPLIERS to match
backend. Fix SharpenOptions to use m1 (not flat) per Sharp 0.34 types.
This commit is contained in:
SnapOtter
2026-05-09 11:26:49 +08:00
parent b61be9e438
commit bdcfb6647c
2 changed files with 13 additions and 1 deletions
@@ -57,6 +57,8 @@ const PRESET_MULTIPLIERS: Record<EnhancementMode, Record<string, number>> = {
saturation: 1.0, saturation: 1.0,
sharpness: 1.0, sharpness: 1.0,
denoise: 1.0, denoise: 1.0,
clahe: 1.0,
normalise: 1.0,
}, },
portrait: { portrait: {
brightness: 0.8, brightness: 0.8,
@@ -65,6 +67,8 @@ const PRESET_MULTIPLIERS: Record<EnhancementMode, Record<string, number>> = {
saturation: 0.6, saturation: 0.6,
sharpness: 0.5, sharpness: 0.5,
denoise: 1.5, denoise: 1.5,
clahe: 0.7,
normalise: 0.8,
}, },
landscape: { landscape: {
brightness: 1.0, brightness: 1.0,
@@ -73,6 +77,8 @@ const PRESET_MULTIPLIERS: Record<EnhancementMode, Record<string, number>> = {
saturation: 1.4, saturation: 1.4,
sharpness: 1.5, sharpness: 1.5,
denoise: 0.5, denoise: 0.5,
clahe: 1.3,
normalise: 1.2,
}, },
"low-light": { "low-light": {
brightness: 1.8, brightness: 1.8,
@@ -81,6 +87,8 @@ const PRESET_MULTIPLIERS: Record<EnhancementMode, Record<string, number>> = {
saturation: 0.8, saturation: 0.8,
sharpness: 1.2, sharpness: 1.2,
denoise: 2.0, denoise: 2.0,
clahe: 1.5,
normalise: 1.5,
}, },
food: { food: {
brightness: 0.8, brightness: 0.8,
@@ -89,6 +97,8 @@ const PRESET_MULTIPLIERS: Record<EnhancementMode, Record<string, number>> = {
saturation: 1.3, saturation: 1.3,
sharpness: 1.2, sharpness: 1.2,
denoise: 0.5, denoise: 0.5,
clahe: 1.1,
normalise: 1.0,
}, },
document: { document: {
brightness: 1.5, brightness: 1.5,
@@ -97,6 +107,8 @@ const PRESET_MULTIPLIERS: Record<EnhancementMode, Record<string, number>> = {
saturation: 0.0, saturation: 0.0,
sharpness: 2.0, sharpness: 2.0,
denoise: 2.0, denoise: 2.0,
clahe: 2.0,
normalise: 1.5,
}, },
}; };
@@ -280,7 +280,7 @@ export function applyCorrections(
const adj = corrections.sharpness * presets.sharpness * scale; const adj = corrections.sharpness * presets.sharpness * scale;
if (adj > 2) { if (adj > 2) {
const sigma = 0.5 + (adj / 100) * 4; const sigma = 0.5 + (adj / 100) * 4;
result = result.sharpen({ sigma, flat: 1.0 }); result = result.sharpen({ sigma, m1: 1.0 });
} }
} }