Documentation
¶
Index ¶
- Constants
- Variables
- func BuildPayload(tokenID, campaignID string) []byte
- func EscapeFFmpegText(s string) string
- func ExtractImageThumbnail(ctx context.Context, inputPath, outputPath string) error
- func ExtractVideoThumbnail(ctx context.Context, inputPath, outputPath string, seekSecs float64) error
- func FileSize(path string) (int64, error)
- func GoInvisibleImageDetect(ctx context.Context, inputPath string, payloadLengthBytes int) (string, error)
- func GoInvisibleImageEmbed(ctx context.Context, inputPath, outputPath, payloadHex string, jpegQuality int) error
- func ImageWatermark(ctx context.Context, p ImageParams) error
- func InvisibleImageDetect(ctx context.Context, inputPath, pythonPath, scriptPath string, ...) (string, error)
- func InvisibleImageEmbed(ctx context.Context, ...) error
- func InvisibleVideoDetect(ctx context.Context, videoPath, pythonPath, detectScript string, ...) ([]string, error)
- func InvisibleVideoEmbed(ctx context.Context, videoPath, payloadHex, pythonPath, embedScript string, ...) error
- func MajorityVote(payloads []string) string
- func ParsePayload(data []byte) (tokenIDHex string, campaignIDHex string, valid bool)
- func ParsePayloadFuzzy(data []byte) (tokenIDHex string, campaignIDHex string, plausible bool)
- func PayloadHex(tokenID, campaignID string) string
- func SHA256File(path string) (string, error)
- func VideoWatermark(ctx context.Context, p VideoParams) error
- func WatermarkText(tokenID, recipientName string) string
- type ImageParams
- type ProbeResult
- type VideoParams
Constants ¶
const ( PayloadVersion = 0x0001 PayloadLength = 16 )
Variables ¶
var MimeToAssetType = map[string]string{
"video/mp4": "video",
"video/quicktime": "video",
"video/x-matroska": "video",
"image/jpeg": "image",
"image/png": "image",
"image/tiff": "image",
"image/webp": "image",
}
var MimeToExt = map[string]string{
"video/mp4": ".mp4",
"video/quicktime": ".mov",
"video/x-matroska": ".mkv",
"image/jpeg": ".jpg",
"image/png": ".png",
"image/tiff": ".tiff",
"image/webp": ".webp",
}
Functions ¶
func BuildPayload ¶
BuildPayload constructs the 16-byte watermark payload per spec section 7.3:
Bytes 0–1: Format version (0x0001) Bytes 2–9: Token ID (8 bytes, truncated SHA-256 of UUID string) Bytes 10–13: Campaign ID (4 bytes, truncated SHA-256 of UUID string) Bytes 14–15: CRC-16 checksum of bytes 0–13
func EscapeFFmpegText ¶
func ExtractImageThumbnail ¶
func ExtractVideoThumbnail ¶
func GoInvisibleImageDetect ¶ added in v1.1.0
func GoInvisibleImageDetect(ctx context.Context, inputPath string, payloadLengthBytes int) (string, error)
GoInvisibleImageDetect extracts the DWT-DCT-SVD watermark from an image file. payloadLengthBytes is the number of payload bytes to extract (e.g., PayloadLength = 16). Returns the hex-encoded payload.
func GoInvisibleImageEmbed ¶ added in v1.1.0
func GoInvisibleImageEmbed(ctx context.Context, inputPath, outputPath, payloadHex string, jpegQuality int) error
GoInvisibleImageEmbed embeds a DWT-DCT-SVD invisible watermark into an image file, matching the Python imwatermark library's dwtDctSvd encoding.
inputPath must be JPEG, PNG, or WebP. outputPath extension determines the output format (JPEG recommended). payloadHex is the 32-character hex string (16 bytes = 128 bits). jpegQuality is the JPEG quality for the output file (e.g., 92).
func ImageWatermark ¶
func ImageWatermark(ctx context.Context, p ImageParams) error
func InvisibleImageDetect ¶
func InvisibleImageDetect(ctx context.Context, inputPath, pythonPath, scriptPath string, payloadLength int) (string, error)
InvisibleImageDetect extracts an invisible DWT-DCT watermark from an image. Returns the hex-encoded payload.
func InvisibleImageEmbed ¶
func InvisibleImageEmbed(ctx context.Context, inputPath, outputPath, payloadHex, pythonPath, scriptPath string, jpegQuality int) error
InvisibleImageEmbed applies an invisible DWT-DCT watermark to an image using the Python invisible-watermark library.
func InvisibleVideoDetect ¶
func InvisibleVideoDetect(ctx context.Context, videoPath, pythonPath, detectScript string, payloadLength int) ([]string, error)
InvisibleVideoDetect extracts key frames from a video and attempts to decode the invisible watermark from each. Returns all detected payload hex strings. The caller should perform majority voting to determine the most likely payload.
func InvisibleVideoEmbed ¶
func InvisibleVideoEmbed(ctx context.Context, videoPath, payloadHex, pythonPath, embedScript string, framesDir string) error
InvisibleVideoEmbed embeds invisible watermarks into evenly-spaced key frames of a video file. Steps:
- Extract N evenly-spaced I-frames from the video
- Embed invisible watermark into each frame
- The watermarked frames are stored alongside the video for detection reference
Note: Full frame re-injection into the video stream is not performed in this version. The visible overlay from FFmpeg is the primary protection for video. Invisible watermarks on extracted frames provide a detection mechanism for clean digital copies.
func MajorityVote ¶
MajorityVote returns the most frequently occurring string from a list.
func ParsePayload ¶
ParsePayload validates and extracts fields from a 16-byte payload. Returns the hex-encoded token ID hash (8 bytes) and campaign ID hash (4 bytes), plus a boolean indicating whether the CRC validated.
func ParsePayloadFuzzy ¶
ParsePayloadFuzzy extracts token and campaign ID hashes from a 16-byte payload without requiring CRC validation. Used as a fallback when CRC fails due to minor bit errors from JPEG re-compression. Returns the hex-encoded hashes and whether the version field is close enough to be plausible.
func PayloadHex ¶
PayloadHex returns the hex-encoded payload string.
func SHA256File ¶
func VideoWatermark ¶
func VideoWatermark(ctx context.Context, p VideoParams) error
func WatermarkText ¶
Types ¶
type ImageParams ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package dct implements a 2D Type-II DCT and its inverse (Type-III).
|
Package dct implements a 2D Type-II DCT and its inverse (Type-III). |
|
Package dwt implements a single-level 2D Haar Discrete Wavelet Transform.
|
Package dwt implements a single-level 2D Haar Discrete Wavelet Transform. |