Skip to main content

TextWatermark

TextWatermark is a library for inserting watermarks into text

Please take a look at our documentation for how to install and use TextWatermark:

Requirements

Tested on Python >= 3.10

Installation

Using Pip

$ pip install textwatermark

From Code

git clone https://github.com/JDArmy/TextWatermark.git

cd TextWatermark

pip install .

# or in editable mode
pip install --editable .

Usage

CMD Line

Insert watermark into text

$ textwatermark -v insert -f './tests/text/number.txt' -m ALPHA_NUMERICAL -t HOMOGRAPH_NUMBERS -x 999 -w 123

Ӏ2𝟑𝟒𝟓Ⳓ𝟟890

Export watermark parameters

$ textwatermark -v insert -f './tests/text/number.txt' -m ALPHA_NUMERICAL -t HOMOGRAPH_NUMBERS -x 999 -w 123 -e

{"tpl_type": "HOMOGRAPH_NUMBERS", "confusables_chars": [], "confusables_chars_key": "", "wm_base": 7, "method": 1, "wm_mode": 5, "wm_len": 7, "wm_loop": false, "start_at": 0, "version": "0.1.2"}

Retrieve the watermark from the text

$ textwatermark -v retrieve -f out.txt -p '{"tpl_type": "HOMOGRAPH_NUMBERS", "confusables_chars": [], "confusables_chars_key": "", "wm_base": 7, "method": 1, "wm_mode": 5, "wm_len": 7, "wm_loop": false, "start_at": 0, "version": "0.1.2"}'

The retrieved watermark is: 123

Coding

'''Sample Example'''
import os

from textwatermark.defines import WMMode
from textwatermark.main import TextWatermark
from textwatermark.template_type import WMTemplateType

# 1.Init TextWatermark instance
wm_mode = WMMode.REAL_NUMBER
wm = TextWatermark(wm_mode=wm_mode)

# 2.Choose a watermark template
wm.set_tpl_type(tpl_type=WMTemplateType.HOMOGRAPH_NUMBERS)

# 3.Set the maximum value of the watermark string
wm_max = '9'*9
wm.set_wm_max(wm_max=wm_max)

# 4.Set the text to be watermarked
wm.set_text_file(path=os.path.abspath('../tests/text/1.txt'))

# 5.Insert watermark string to text
wm_str = '123456789'
wm_text = wm.insert_watermark(wm_str=wm_str)
print(wm_text)

##############################################################

# Save the parameters to retrieve the watermark
params = wm.export_params()

# retrieve the watermark
wm_out_str = TextWatermark.retrieve_watermark(wm_text=wm_text, params=params)

assert wm_out_str == wm_str

More

See: Documents

Metadata

Release files for textwatermark 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for textwatermark 0.3.2
File Size Uploaded
textwatermark-0.3.2.tar.gz 34.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for textwatermark 0.3.2
File Interpreter ABI Platform
textwatermark-0.3.2-py3-none-any.whl Python 3 none any Details

Total release size: 76.8 kB

Release files / textwatermark-0.3.2.tar.gz

Download URL textwatermark-0.3.2.tar.gz
Size 34.5 kB
Tags Source
SHA-256 checksum
How to use checksums
08e799104ca7dca6a260345b4b0d60c109611b7465dd11c40448db76703b5243
BLAKE2b-256 checksum
How to use checksums
bc51601fc9962ea613f14599a32bfcbdea6c48655b69e28f17abd85708ee72a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release files / textwatermark-0.3.2-py3-none-any.whl

Download URL textwatermark-0.3.2-py3-none-any.whl
Size 42.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d76968ac72bf7652b5d76e9f45e9a915546312f4500f538fef980ff527bcbb89
BLAKE2b-256 checksum
How to use checksums
1eb82bf55a72a347797adf78c504e2d131259531e884f2d8822e6d81bef7d363
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.10

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page