traceless-watermark 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. traceless_watermark-0.1.0/LICENSE +201 -0
  2. traceless_watermark-0.1.0/PKG-INFO +204 -0
  3. traceless_watermark-0.1.0/README.md +189 -0
  4. traceless_watermark-0.1.0/THIRD_PARTY_NOTICES.md +93 -0
  5. traceless_watermark-0.1.0/pyproject.toml +23 -0
  6. traceless_watermark-0.1.0/pyproject.toml.orig +22 -0
  7. traceless_watermark-0.1.0/src/traceless_watermark/BufferPoolReservation.py +27 -0
  8. traceless_watermark-0.1.0/src/traceless_watermark/ChannelScales.py +27 -0
  9. traceless_watermark-0.1.0/src/traceless_watermark/TracelessWatermark.py +523 -0
  10. traceless_watermark-0.1.0/src/traceless_watermark/WarmUpResult.py +9 -0
  11. traceless_watermark-0.1.0/src/traceless_watermark/WatermarkBlockSize.py +15 -0
  12. traceless_watermark-0.1.0/src/traceless_watermark/WatermarkErrorCorrectionLevel.py +23 -0
  13. traceless_watermark-0.1.0/src/traceless_watermark/WatermarkErrors.py +56 -0
  14. traceless_watermark-0.1.0/src/traceless_watermark/WatermarkExecutionMode.py +13 -0
  15. traceless_watermark-0.1.0/src/traceless_watermark/WatermarkResult.py +38 -0
  16. traceless_watermark-0.1.0/src/traceless_watermark/__init__.py +55 -0
  17. traceless_watermark-0.1.0/src/traceless_watermark/internal/EmbedDwtDctSvd.py +166 -0
  18. traceless_watermark-0.1.0/src/traceless_watermark/internal/EmbedDwtDctSvdWebGpu.py +508 -0
  19. traceless_watermark-0.1.0/src/traceless_watermark/internal/EmbedWatermarker.py +14 -0
  20. traceless_watermark-0.1.0/src/traceless_watermark/internal/GpuSupport.py +16 -0
  21. traceless_watermark-0.1.0/src/traceless_watermark/internal/ImageSizeValidator.py +100 -0
  22. traceless_watermark-0.1.0/src/traceless_watermark/internal/ReedSolo.py +1180 -0
  23. traceless_watermark-0.1.0/src/traceless_watermark/internal/ResourceLimitError.py +6 -0
  24. traceless_watermark-0.1.0/src/traceless_watermark/internal/WatermarkTextValidator.py +11 -0
  25. traceless_watermark-0.1.0/src/traceless_watermark/internal/WebGpuBufferPool.py +298 -0
  26. traceless_watermark-0.1.0/src/traceless_watermark/internal/WebGpuPipelines.py +179 -0
  27. traceless_watermark-0.1.0/src/traceless_watermark/internal/WebGpuResources.py +114 -0
  28. traceless_watermark-0.1.0/src/traceless_watermark/internal/__init__.py +1 -0
  29. traceless_watermark-0.1.0/src/traceless_watermark/internal/shaders/watermarkKernels.py +540 -0
  30. traceless_watermark-0.1.0/src/traceless_watermark/internal/utils/DCTUtils.py +52 -0
  31. traceless_watermark-0.1.0/src/traceless_watermark/internal/utils/SVDUtils.py +85 -0
  32. traceless_watermark-0.1.0/src/traceless_watermark/internal/utils/WaveletUtils.py +397 -0
  33. traceless_watermark-0.1.0/src/traceless_watermark/internal/utils/__init__.py +1 -0
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,204 @@
1
+ Metadata-Version: 2.4
2
+ Name: traceless-watermark
3
+ Version: 0.1.0
4
+ Summary: Add and extract invisible image watermarks with Reed-Solomon error correction and optional GPU acceleration.
5
+ License-Expression: Apache-2.0
6
+ License-File: LICENSE
7
+ License-File: THIRD_PARTY_NOTICES.md
8
+ Requires-Dist: numpy>=2.5.2
9
+ Requires-Dist: opencv-python-headless>=5.0.0.93
10
+ Requires-Dist: pywavelets>=1.9.0
11
+ Requires-Dist: wgpu>=0.32.0 ; extra == 'gpu'
12
+ Requires-Python: >=3.12
13
+ Provides-Extra: gpu
14
+ Description-Content-Type: text/markdown
15
+
16
+ # Traceless Watermark for Python
17
+
18
+ `TracelessWatermark-Python` is a Python image-processing library for adding and extracting invisible watermarks.
19
+
20
+ This package uses the DWT-DCT-SVD implementation from ShieldMnt's Python [invisible-watermark](https://github.com/ShieldMnt/invisible-watermark) library and incorporates [Reed-Solomon error correction](https://github.com/tomerfiliba-org/reedsolomon).
21
+
22
+ Encoding and decoding work with NumPy image arrays. GPU mode uses WebGPU when available and falls back to the CPU path otherwise.
23
+
24
+ Traceless Watermark also includes libraries for iOS, Android, and browsers.
25
+
26
+ ## Requirements
27
+
28
+ - Python 3.12 or later
29
+ - Optional WebGPU dependencies for the GPU implementation
30
+
31
+ ## Usage
32
+
33
+ ```python
34
+ import asyncio
35
+ import cv2
36
+
37
+ from traceless_watermark import TracelessWatermark, WatermarkSuccess
38
+
39
+ async def main():
40
+ image = cv2.imread("input.jpg", cv2.IMREAD_COLOR)
41
+ watermark = TracelessWatermark()
42
+ watermark_text = "Example watermark"
43
+
44
+ encode_result = await watermark.encode_text(image, watermark_text)
45
+
46
+ if isinstance(encode_result, WatermarkSuccess):
47
+ watermarked_image = encode_result.value
48
+ cv2.imwrite("watermarked.png", watermarked_image)
49
+
50
+ decode_result = await watermark.decode_text(
51
+ watermarked_image,
52
+ byte_count=len(watermark_text.encode("utf-8")),
53
+ )
54
+
55
+ if isinstance(decode_result, WatermarkSuccess):
56
+ print(decode_result.value.payload)
57
+ else:
58
+ print("Decode failed:", decode_result.error)
59
+ else:
60
+ print("Encode failed:", encode_result.error)
61
+
62
+ asyncio.run(main())
63
+ ```
64
+
65
+ ## API
66
+
67
+ Traceless Watermark has the following methods used for encoding and decoding watermarks, and all move off the event loop thread to avoid blocking async callers.
68
+
69
+ Text-based APIs:
70
+
71
+ ```python
72
+ async def encode_text(
73
+ image: np.ndarray,
74
+ text: str,
75
+ ) -> WatermarkSuccess[np.ndarray] | WatermarkFailure[WatermarkEncodeError]
76
+
77
+ async def decode_text(
78
+ image: np.ndarray,
79
+ byte_count: int,
80
+ ) -> WatermarkSuccess[DecodedPayload[str]] | WatermarkFailure[WatermarkDecodeError]
81
+ ```
82
+
83
+ Byte-based APIs:
84
+
85
+ ```python
86
+ async def encode_bytes(
87
+ image: np.ndarray,
88
+ payload: bytes,
89
+ ) -> WatermarkSuccess[np.ndarray] | WatermarkFailure[WatermarkEncodeError]
90
+
91
+ async def decode_bytes(
92
+ image: np.ndarray,
93
+ byte_count: int,
94
+ ) -> WatermarkSuccess[DecodedPayload[bytes]] | WatermarkFailure[WatermarkDecodeError]
95
+ ```
96
+
97
+ Results are returned as `WatermarkSuccess(value)` or `WatermarkFailure(error)`. Decode success values contain a `DecodedPayload`; use `payload` for the recovered text or bytes, and `correction_usage` for the fraction of the Reed-Solomon correction budget used during recovery.
98
+
99
+ ## Options
100
+
101
+ Options can be set when creating the `TracelessWatermark` object.
102
+
103
+ ```python
104
+ watermark = TracelessWatermark(
105
+ scales=ChannelScales(),
106
+ block_size=WatermarkBlockSize.FOUR,
107
+ correction_level=StandardWatermarkErrorCorrectionLevel.MEDIUM,
108
+ execution_mode=WatermarkExecutionMode.GPU,
109
+ )
110
+ ```
111
+
112
+ ### Channel Scales
113
+
114
+ The scale controls how strongly the watermark is written into each YUV channel.
115
+
116
+ Using more channels can improve decode reliability, but costs more work.
117
+
118
+ ```python
119
+ ChannelScales(y_channel=0, u_channel=36, v_channel=36) # Default values
120
+ ```
121
+
122
+ Higher YUV color scale values improve watermark resilience at the cost of visual artifacting.
123
+
124
+ ### Execution Mode
125
+
126
+ Switch between CPU and GPU environments when performing watermarks.
127
+
128
+ ```python
129
+ WatermarkExecutionMode.CPU
130
+ WatermarkExecutionMode.GPU
131
+ WatermarkExecutionMode.REFERENCE
132
+ ```
133
+
134
+ `GPU` uses WebGPU and is the default. When WebGPU is unavailable, it falls back to `CPU`. `REFERENCE` uses the local reference implementation for comparison and debugging.
135
+
136
+ ### Error Correction
137
+
138
+ Error correction levels are provided for better watermark survivability.
139
+
140
+ ```python
141
+ StandardWatermarkErrorCorrectionLevel.NONE
142
+ StandardWatermarkErrorCorrectionLevel.LOW
143
+ StandardWatermarkErrorCorrectionLevel.MEDIUM
144
+ StandardWatermarkErrorCorrectionLevel.QUARTILE
145
+ StandardWatermarkErrorCorrectionLevel.HIGH
146
+ CustomWatermarkErrorCorrectionLevel(recovery_rate)
147
+ ```
148
+
149
+ The levels mimic QR code error correction levels. The default is `MEDIUM`.
150
+
151
+ ### Block Size
152
+
153
+ Block size controls the squares used for embedding watermark bits.
154
+
155
+ ```python
156
+ WatermarkBlockSize.FOUR
157
+ WatermarkBlockSize.EIGHT
158
+ ```
159
+
160
+ `FOUR` is the recommended default. `EIGHT` is available for tuning and experiments.
161
+
162
+ ## GPU Cold Starts
163
+
164
+ If you know the sizes of your images and watermark in advance, you can pass a buffer-pool reservation during warmup to reduce cold start latency.
165
+
166
+ ```python
167
+ warm_up_result = await TracelessWatermark.warm_up(
168
+ BufferPoolReservation(
169
+ width=image_width,
170
+ height=image_height,
171
+ byte_count=len("Example watermark".encode("utf-8")),
172
+ correction_level=StandardWatermarkErrorCorrectionLevel.MEDIUM, # Default parameter
173
+ )
174
+ )
175
+ ```
176
+
177
+ `warm_up` returns `WarmUpResult.Success`, `WarmUpResult.GpuUnavailable`, or `WarmUpResult.ReservationTooLarge`.
178
+
179
+ Call `clean_up()` when an app wants to release shared GPU resources:
180
+
181
+ ```python
182
+ await TracelessWatermark.clean_up()
183
+ ```
184
+
185
+ ## Image Notes
186
+
187
+ - Images should be `np.uint8` arrays.
188
+ - Supported shapes are `(height, width, 3)` and `(height, width, 4)`.
189
+ - Channel order is BGR/BGRA, matching OpenCV.
190
+ - Decode length is the original UTF-8 byte length.
191
+ - Resizing, cropping, rotating, taking screenshots, or heavy recompression damages the signal.
192
+ - Higher-resolution images increase watermark capacity, but require more processing time and memory.
193
+ - Transparent images are not supported due to alpha premultiplication.
194
+ - Encoded output file sizes are typically larger than the source images.
195
+ - Cross-platform compatibility may still encounter edge cases.
196
+ - Currently Traceless Watermark is meant to watermark one image at a time.
197
+
198
+ ## Development
199
+
200
+ See [PLATFORM_DETAILS.md](PLATFORM_DETAILS.md) for local setup, development environment tips, running the example app, and testing changes.
201
+
202
+ ## License
203
+
204
+ Apache-2.0. See [`LICENSE`](LICENSE).
@@ -0,0 +1,189 @@
1
+ # Traceless Watermark for Python
2
+
3
+ `TracelessWatermark-Python` is a Python image-processing library for adding and extracting invisible watermarks.
4
+
5
+ This package uses the DWT-DCT-SVD implementation from ShieldMnt's Python [invisible-watermark](https://github.com/ShieldMnt/invisible-watermark) library and incorporates [Reed-Solomon error correction](https://github.com/tomerfiliba-org/reedsolomon).
6
+
7
+ Encoding and decoding work with NumPy image arrays. GPU mode uses WebGPU when available and falls back to the CPU path otherwise.
8
+
9
+ Traceless Watermark also includes libraries for iOS, Android, and browsers.
10
+
11
+ ## Requirements
12
+
13
+ - Python 3.12 or later
14
+ - Optional WebGPU dependencies for the GPU implementation
15
+
16
+ ## Usage
17
+
18
+ ```python
19
+ import asyncio
20
+ import cv2
21
+
22
+ from traceless_watermark import TracelessWatermark, WatermarkSuccess
23
+
24
+ async def main():
25
+ image = cv2.imread("input.jpg", cv2.IMREAD_COLOR)
26
+ watermark = TracelessWatermark()
27
+ watermark_text = "Example watermark"
28
+
29
+ encode_result = await watermark.encode_text(image, watermark_text)
30
+
31
+ if isinstance(encode_result, WatermarkSuccess):
32
+ watermarked_image = encode_result.value
33
+ cv2.imwrite("watermarked.png", watermarked_image)
34
+
35
+ decode_result = await watermark.decode_text(
36
+ watermarked_image,
37
+ byte_count=len(watermark_text.encode("utf-8")),
38
+ )
39
+
40
+ if isinstance(decode_result, WatermarkSuccess):
41
+ print(decode_result.value.payload)
42
+ else:
43
+ print("Decode failed:", decode_result.error)
44
+ else:
45
+ print("Encode failed:", encode_result.error)
46
+
47
+ asyncio.run(main())
48
+ ```
49
+
50
+ ## API
51
+
52
+ Traceless Watermark has the following methods used for encoding and decoding watermarks, and all move off the event loop thread to avoid blocking async callers.
53
+
54
+ Text-based APIs:
55
+
56
+ ```python
57
+ async def encode_text(
58
+ image: np.ndarray,
59
+ text: str,
60
+ ) -> WatermarkSuccess[np.ndarray] | WatermarkFailure[WatermarkEncodeError]
61
+
62
+ async def decode_text(
63
+ image: np.ndarray,
64
+ byte_count: int,
65
+ ) -> WatermarkSuccess[DecodedPayload[str]] | WatermarkFailure[WatermarkDecodeError]
66
+ ```
67
+
68
+ Byte-based APIs:
69
+
70
+ ```python
71
+ async def encode_bytes(
72
+ image: np.ndarray,
73
+ payload: bytes,
74
+ ) -> WatermarkSuccess[np.ndarray] | WatermarkFailure[WatermarkEncodeError]
75
+
76
+ async def decode_bytes(
77
+ image: np.ndarray,
78
+ byte_count: int,
79
+ ) -> WatermarkSuccess[DecodedPayload[bytes]] | WatermarkFailure[WatermarkDecodeError]
80
+ ```
81
+
82
+ Results are returned as `WatermarkSuccess(value)` or `WatermarkFailure(error)`. Decode success values contain a `DecodedPayload`; use `payload` for the recovered text or bytes, and `correction_usage` for the fraction of the Reed-Solomon correction budget used during recovery.
83
+
84
+ ## Options
85
+
86
+ Options can be set when creating the `TracelessWatermark` object.
87
+
88
+ ```python
89
+ watermark = TracelessWatermark(
90
+ scales=ChannelScales(),
91
+ block_size=WatermarkBlockSize.FOUR,
92
+ correction_level=StandardWatermarkErrorCorrectionLevel.MEDIUM,
93
+ execution_mode=WatermarkExecutionMode.GPU,
94
+ )
95
+ ```
96
+
97
+ ### Channel Scales
98
+
99
+ The scale controls how strongly the watermark is written into each YUV channel.
100
+
101
+ Using more channels can improve decode reliability, but costs more work.
102
+
103
+ ```python
104
+ ChannelScales(y_channel=0, u_channel=36, v_channel=36) # Default values
105
+ ```
106
+
107
+ Higher YUV color scale values improve watermark resilience at the cost of visual artifacting.
108
+
109
+ ### Execution Mode
110
+
111
+ Switch between CPU and GPU environments when performing watermarks.
112
+
113
+ ```python
114
+ WatermarkExecutionMode.CPU
115
+ WatermarkExecutionMode.GPU
116
+ WatermarkExecutionMode.REFERENCE
117
+ ```
118
+
119
+ `GPU` uses WebGPU and is the default. When WebGPU is unavailable, it falls back to `CPU`. `REFERENCE` uses the local reference implementation for comparison and debugging.
120
+
121
+ ### Error Correction
122
+
123
+ Error correction levels are provided for better watermark survivability.
124
+
125
+ ```python
126
+ StandardWatermarkErrorCorrectionLevel.NONE
127
+ StandardWatermarkErrorCorrectionLevel.LOW
128
+ StandardWatermarkErrorCorrectionLevel.MEDIUM
129
+ StandardWatermarkErrorCorrectionLevel.QUARTILE
130
+ StandardWatermarkErrorCorrectionLevel.HIGH
131
+ CustomWatermarkErrorCorrectionLevel(recovery_rate)
132
+ ```
133
+
134
+ The levels mimic QR code error correction levels. The default is `MEDIUM`.
135
+
136
+ ### Block Size
137
+
138
+ Block size controls the squares used for embedding watermark bits.
139
+
140
+ ```python
141
+ WatermarkBlockSize.FOUR
142
+ WatermarkBlockSize.EIGHT
143
+ ```
144
+
145
+ `FOUR` is the recommended default. `EIGHT` is available for tuning and experiments.
146
+
147
+ ## GPU Cold Starts
148
+
149
+ If you know the sizes of your images and watermark in advance, you can pass a buffer-pool reservation during warmup to reduce cold start latency.
150
+
151
+ ```python
152
+ warm_up_result = await TracelessWatermark.warm_up(
153
+ BufferPoolReservation(
154
+ width=image_width,
155
+ height=image_height,
156
+ byte_count=len("Example watermark".encode("utf-8")),
157
+ correction_level=StandardWatermarkErrorCorrectionLevel.MEDIUM, # Default parameter
158
+ )
159
+ )
160
+ ```
161
+
162
+ `warm_up` returns `WarmUpResult.Success`, `WarmUpResult.GpuUnavailable`, or `WarmUpResult.ReservationTooLarge`.
163
+
164
+ Call `clean_up()` when an app wants to release shared GPU resources:
165
+
166
+ ```python
167
+ await TracelessWatermark.clean_up()
168
+ ```
169
+
170
+ ## Image Notes
171
+
172
+ - Images should be `np.uint8` arrays.
173
+ - Supported shapes are `(height, width, 3)` and `(height, width, 4)`.
174
+ - Channel order is BGR/BGRA, matching OpenCV.
175
+ - Decode length is the original UTF-8 byte length.
176
+ - Resizing, cropping, rotating, taking screenshots, or heavy recompression damages the signal.
177
+ - Higher-resolution images increase watermark capacity, but require more processing time and memory.
178
+ - Transparent images are not supported due to alpha premultiplication.
179
+ - Encoded output file sizes are typically larger than the source images.
180
+ - Cross-platform compatibility may still encounter edge cases.
181
+ - Currently Traceless Watermark is meant to watermark one image at a time.
182
+
183
+ ## Development
184
+
185
+ See [PLATFORM_DETAILS.md](PLATFORM_DETAILS.md) for local setup, development environment tips, running the example app, and testing changes.
186
+
187
+ ## License
188
+
189
+ Apache-2.0. See [`LICENSE`](LICENSE).
@@ -0,0 +1,93 @@
1
+ # Third-Party Notices
2
+
3
+ Third-party code and assets retain the licenses listed below; Traceless Watermark's own license is [Apache-2.0](LICENSE).
4
+
5
+ This inventory covers copied code and assets, not all package-manager dependencies.
6
+
7
+ ## Library code
8
+
9
+ ### Reed-Solomon (reedsolo)
10
+
11
+ - Upstream: [tomerfiliba-org/reedsolomon](https://github.com/tomerfiliba-org/reedsolomon).
12
+ - Local implementation: [`src/traceless_watermark/internal/ReedSolo.py`](src/traceless_watermark/internal/ReedSolo.py).
13
+ - Origin: Vendored Python implementation with isolated module state.
14
+ - Upstream baseline: [`796639c`](https://github.com/tomerfiliba-org/reedsolomon/commit/796639ca4953f1f465ea60682ad4a826239137e7) (`2.1.3b1`), verified against the vendored Python implementation.
15
+ - Local Python changes: formatting, comments, and `xrange = range` in place of the Python 2 compatibility fallback.
16
+ - License: [Unlicense or MIT-0](https://github.com/tomerfiliba-org/reedsolomon/blob/796639ca4953f1f465ea60682ad4a826239137e7/LICENSE); MIT-0 text reproduced below.
17
+
18
+ Original source copyrights:
19
+
20
+ ```text
21
+ Copyright (c) 2012-2015 Tomer Filiba <tomerfiliba@gmail.com>
22
+ Copyright (c) 2015 rotorgit
23
+ Copyright (c) 2015-2023 Stephen Larroque <LRQ3000@gmail.com>
24
+ ```
25
+
26
+ MIT No Attribution (MIT-0) license text:
27
+
28
+ ```text
29
+ Copyright 2013-2023 Tomer Filiba & Stephen Larroque
30
+
31
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so.
32
+
33
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34
+ ```
35
+
36
+ ### invisible-watermark
37
+
38
+ - Upstream: [ShieldMnt/invisible-watermark](https://github.com/ShieldMnt/invisible-watermark).
39
+ - Usage: DWT-DCT-SVD watermarking, adapted for platform-specific APIs, execution backends, and Reed-Solomon integration.
40
+ - License: [MIT](https://github.com/ShieldMnt/invisible-watermark/blob/main/LICENSE).
41
+
42
+ ```text
43
+ MIT License
44
+
45
+ Copyright (c) 2021 ShieldMnt
46
+
47
+ Permission is hereby granted, free of charge, to any person obtaining a copy
48
+ of this software and associated documentation files (the "Software"), to deal
49
+ in the Software without restriction, including without limitation the rights
50
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
51
+ copies of the Software, and to permit persons to whom the Software is
52
+ furnished to do so, subject to the following conditions:
53
+ The above copyright notice and this permission notice shall be included in all
54
+ copies or substantial portions of the Software.
55
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
56
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
57
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
58
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
59
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
60
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
61
+ SOFTWARE.
62
+ ```
63
+
64
+ ## Test images
65
+
66
+ Repository test fixtures, not library runtime assets.
67
+
68
+ Original download revisions and modifications to the photographs were not recorded.
69
+
70
+ ### Cherries
71
+
72
+ - Local file: [`images/cherries.jpg`](images/cherries.jpg).
73
+ - Creator: Schueler-Design.
74
+ - Source: [Cherries, Cherry tree, Branch on Pixabay](https://pixabay.com/photos/cherries-cherry-tree-branch-fruit-826113/).
75
+ - License: [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/); [full text](https://creativecommons.org/publicdomain/zero/1.0/legalcode).
76
+ - Published July 1, 2015, before Pixabay's January 9, 2019 CC0 cutoff; see [section 4 of Pixabay's terms](https://pixabay.com/service/terms/).
77
+
78
+ ### Chocolate chip cookies
79
+
80
+ - Local file: [`images/chocolate-chip-cookies.jpg`](images/chocolate-chip-cookies.jpg).
81
+ - Creator: Lisa Fotios.
82
+ - Source: [Chocolate Chip Cookies on NegativeSpace](https://negativespace.co/chocolate-chip-cookies-2/).
83
+ - License: [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/), as listed by the source; [full text](https://creativecommons.org/publicdomain/zero/1.0/legalcode).
84
+
85
+ ## Example-only dependencies
86
+
87
+ ### PySide6 / Qt for Python
88
+
89
+ - Project: [Qt for Python](https://doc.qt.io/qtforpython-6/), by The Qt Company and contributors.
90
+ - Usage: The [desktop example](example/traceless_watermark_example/pyproject.toml) uses PySide6's QtCore, QtGui, and QtWidgets; the library does not depend on PySide6.
91
+ - Distribution: Installed separately, not vendored.
92
+ - Licensing: LGPLv3/GPLv3 or commercial terms, depending on the components; see [upstream license details](https://doc.qt.io/qtforpython-6/licenses.html).
93
+ - Bundled executables require a separate review of shipped components, notices, license texts, and source/relinking obligations; see [Qt's LGPL guidance](https://www.qt.io/development/open-source-lgpl-obligations).