Feature (frontend): Add invisible watermark decoder node. by lstein · Pull Request #8967 · invoke-ai/InvokeAI
Summary
Adds a workflow node to decode invisible watermarks previously embedded with the existing Add Invisible Watermark node. Returns the watermark text as a string, or an empty string if no watermark is detected or decoding fails.
invokeai/backend/image_util/invisible_watermark.py
- Added
decode_watermark(image, length=8)classmethod toInvisibleWatermark - Uses vendored
WatermarkDecoder("bytes", length * 8)withdwtDct— mirrors the encoding path - Returns decoded UTF-8 string stripped of null bytes; catches all exceptions and returns
""
invokeai/app/invocations/image.py
- Added
DecodeInvisibleWatermarkInvocationnode ("decode_watermark") - Inputs:
image: ImageField,length: int(bytes, default8— matches the default"InvokeAI"watermark) - Output:
StringOutputwith the decoded watermark text
The length parameter must match the byte length of the text used during encoding (e.g., 8 for "InvokeAI").
Related Issues / Discussions
QA Instructions
- Create a two-node workflow in which the existing "Add Invisible Watermark" is connected to the new "Decode Invisible Watermark" node.
- Feed an image to "Add Invisible Watermark" using its default settings.
- Confirm that the "Decode Invisible Watermark" returns "InvokeAI".
- Create a two-node workflow in which the "Image Primitive" node is connected directly to "Decode Invisible Watermark".
- Feed the workflow an image that does not have a watermark.
- Confirm that the output of the decode node is the empty string. ""
Merge Plan
Simple merge.
Checklist
- The PR has a short but descriptive title, suitable for a changelog
- Tests added / updated (if applicable)
- ❗Changes to a redux slice have a corresponding migration
- Documentation added / updated (if applicable)
- Updated
What's Newcopy (if doing a release after this PR)