/apertaluce/
Try it in your browser: mark a picture, lay the marked copy over the original, and read the mark back from copies your browser re-saves, reduces, cuts and turns.
.------------------------------------------------------------------------.
| .--. __ __ .--. |
| | | ____ _____ ___ _____/ /_____ _/ /_ __________ | | |
| '--' / __ `/ __ \/ _ \/ ___/ __/ __ `/ / / / / ___/ _ \ '--' |
| / /_/ / /_/ / __/ / / /_/ /_/ / / /_/ / /__/ __/ |
| [+] \__,_/ .___/\___/_/ \__/\__,_/_/\__,_/\___/\___/ [+] |
| /_/ |
| .--. .--. |
| | | I n v i s i b l e M a r k s | | |
| '--' '--' |
'------------------------------------------------------------------------'
Invisible marks for pictures, sound and video. Keyed, survive re-encoding and editing. No dependencies, no codecs, runs anywhere JavaScript does; the picture embedder's long loops run in a small compiled kernel where WebAssembly is at hand.
Install
npm install apertaluce
Node 20+, Bun, Deno, browsers, edge runtimes. ESM with types.
import { derivePixelKey, embedPixelMark, detectPixelMark } from 'apertaluce/image';
import { deriveAudioKey, embedAudioMark, detectAudioMark } from 'apertaluce/audio';
import { frameMarkOverlayPgm, detectFrameMark } from 'apertaluce/video';
const pixels = await derivePixelKey(secret);
embedPixelMark(rgba, pixels); // in place
detectPixelMark(suspect, pixels).detected;
const sound = await deriveAudioKey(secret);
embedAudioMark([left, right], 44_100, sound); // in place
detectAudioMark(samples, 48_000, sound).detected;
const overlay = frameMarkOverlayPgm(1280, 720, pixels); // blend onto every frame's luma
detectFrameMark(frames, pixels).detected; // a dozen frames of the suspect
A mark says one thing: this was marked with this key. No payload. Reading or forging it needs the key. Decoding and encoding stay with the host: the library takes pixels and samples.
Marks
| Mark |
|
| Picture |
Keyed tile: single-level grain on flat colour, lines and edges, stronger in texture; crop, turn, screen capture |
| Video |
The same tile on every frame; H.264/HEVC/VP9 re-encodes, reduction, crop, screen recording |
| Sound |
Keyed sequence under the sound; MP3/AAC/Opus, resampling, trimming, noise, mixing, echo |
| Sound |
Keyed balance of neighbouring bands; another tempo, another speed (partly, see Limits) |
API
apertaluce/image:
| Function |
|
derivePixelKey(secret, id?) |
Key from a secret of 128 bits or more |
embedPixelMark(image, key, options?) |
Marks RGBA pixels in place; returns the PSNR |
detectPixelMark(image, key, options?) |
detected, score and the cut it was held against, rotation, mirroring |
pixelMarkPlane(width, height, key, tiles?) |
The mark alone, for pipelines that add it themselves |
pictureFingerprint(image) |
256-bit perceptual fingerprint, 64 hex digits |
fingerprintDistance(a, b) |
Bits two fingerprints differ in |
apertaluce/audio:
| Function |
|
deriveAudioKey(secret, id?) |
Key from a secret of 128 bits or more |
embedAudioMark(channels, rate, key, options?) |
Marks Float32 samples in place; returns sound over mark |
createAudioMarker(key, rate, options?) |
Streaming: process(chunk), flush(), delay |
detectAudioMark(channels, rate, key, options?) |
detected, score, layer, tempo and pitch |
resample(samples, from, to) |
Windowed-sinc rate conversion |
apertaluce/video:
| Function |
|
frameMarkOverlay(width, height, key, options?) |
Grey plane, 128 = leave the pixel |
frameMarkOverlayPgm(...) |
The same as a PGM file for ffmpeg |
detectFrameMark(frames, key, options?) |
Reads the mean of the frames, then single frames |
# One overlay for the whole video; only the luma plane meets it.
ffmpeg -i in.mp4 -loop 1 -i overlay.pgm -filter_complex \
"[0:v]format=yuv420p,extractplanes=y+u+v[y][u][v];[1:v]format=gray[o];[y][o]blend=all_mode=grainmerge:shortest=1[m];[m][u][v]mergeplanes=0x001020:yuv420p" out.mp4
Options: strength (picture, sound), balance: false (sound: skip the second layer and its 0.2 s delay), search: false (sound: skip the tempo and pitch search), amplitude and tilesPerShortSide (video).
Measured
Full tables in docs/MEASURED.md. Found / tried, 2026-12-01:
| Mark |
Hosts |
Held |
Unmarked |
| Picture |
29 pictures |
JPEG 50, half size, crop, turn, mirror, pen strokes, screen capture to 0.5 |
0/2,162 |
| Video |
10 clips |
CRF 38, 240p, HEVC, VP9, quarter crop, screen recording |
0/30 |
| Sound, sequence |
4 speech pieces |
MP3 32, Opus 12, telephone band, 1 s excerpt, noise at 10 dB |
0/12 |
| Sound, balance |
3 speech pieces |
10% faster with pitch kept, 5% faster |
0/9 |
Limits
- Nobody has listened to marked sound or watched marked video under controlled conditions. The levels come from masking rules and the numbers above.
- Sound 1% faster, 25% faster, or shifted in pitch alone is not recognised.
- The sound bench covers speech. Music has not been measured.
- Under about a second of sound there is too little mark to read.
- The picture mark does not touch lines and edges: they get the single-level grain flat colour gets. So a flat drawing saved as WebP, or reduced to under a half and compressed, is not recognised by it, and no thumbnail of 400 px or less is. Whole pictures made small are what the fingerprint is for.
- Whoever holds the key can mark anything. The mark proves the key was used, not who used it.
Develop
npm run tsc && npm test
npm run build:kernel # after a change to native/kernel.c; needs clang with wasm32 and wasm-ld
npm run build:demo # the demo page, into site/ (serve that folder to look at it)
node bench/audio.ts --dir <folder of audio or video> # needs ffmpeg
node bench/video.ts --dir <folder of videos>
Release: gh workflow run release.yml -R lofcz/apertaluce -f release_type=minor. First publish of a new package name: npm run bootstrap:publish (npm login, publish, trusted publisher).
License
MIT