Spaces:
Running
Running
| import type { PresetName, WatermarkConfig } from './types.js'; | |
| /** Mid-frequency DCT coefficients (zigzag positions 3β14, 12 coeffs) */ | |
| const MID_FREQ_ZIGZAG = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]; | |
| /** Low+mid frequency coefficients (zigzag 1β20, 20 coeffs) β survive heavy compression */ | |
| const LOW_MID_FREQ_ZIGZAG = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]; | |
| /** Low frequency coefficients (zigzag 1β10, 10 coeffs) β survive extreme compression */ | |
| const LOW_FREQ_ZIGZAG = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; | |
| export const PRESETS: Record<PresetName, WatermarkConfig> = { | |
| light: { | |
| alpha: 0.10, | |
| delta: 50, | |
| tilePeriod: 256, | |
| bch: { n: 63, k: 36, t: 5, m: 6 }, | |
| crc: { bits: 4 }, | |
| dwtLevels: 2, | |
| zigzagPositions: MID_FREQ_ZIGZAG, | |
| perceptualMasking: true, | |
| temporalFrames: 1, | |
| }, | |
| moderate: { | |
| alpha: 0.13, | |
| delta: 62, | |
| tilePeriod: 240, | |
| bch: { n: 63, k: 36, t: 5, m: 6 }, | |
| crc: { bits: 4 }, | |
| dwtLevels: 2, | |
| zigzagPositions: MID_FREQ_ZIGZAG, | |
| perceptualMasking: true, | |
| temporalFrames: 1, | |
| }, | |
| strong: { | |
| alpha: 0.26, | |
| delta: 110, | |
| tilePeriod: 208, | |
| bch: { n: 63, k: 36, t: 5, m: 6 }, | |
| crc: { bits: 4 }, | |
| dwtLevels: 2, | |
| zigzagPositions: LOW_MID_FREQ_ZIGZAG, | |
| perceptualMasking: true, | |
| temporalFrames: 1, | |
| }, | |
| fortress: { | |
| alpha: 0.35, | |
| delta: 150, | |
| tilePeriod: 192, | |
| bch: { n: 63, k: 36, t: 5, m: 6 }, | |
| crc: { bits: 4 }, | |
| dwtLevels: 2, | |
| zigzagPositions: LOW_MID_FREQ_ZIGZAG, | |
| perceptualMasking: true, | |
| temporalFrames: 1, | |
| }, | |
| }; | |
| /** | |
| * Get a preset configuration by name | |
| */ | |
| export function getPreset(name: PresetName): WatermarkConfig { | |
| return { ...PRESETS[name] }; | |
| } | |
| /** | |
| * Preset descriptions for the UI | |
| */ | |
| export const PRESET_DESCRIPTIONS: Record<PresetName, string> = { | |
| light: 'π€οΈ Lightest touch. Near-invisible, survives mild compression.', | |
| moderate: 'β‘ Near-invisible with perceptual masking. Slightly stronger than light.', | |
| strong: 'π‘οΈ Stronger embedding across more frequencies. Handles rescaling well.', | |
| fortress: 'π° Maximum robustness. Survives heavy compression and color adjustments.', | |
| }; | |