textwatermark


Nametextwatermark JSON
Version 0.3.2 PyPI version JSON
download
home_pagehttps://textwatermark.jd.army/
SummaryA watermark library for text.
upload_time2023-03-15 05:46:40
maintainer
docs_urlNone
authorMonyer
requires_python>=3.10,<4.0
licenseApache
keywords watermark text blind
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # TextWatermark

TextWatermark is a library for inserting watermarks into text

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

- [Website](https://textwatermark.jd.army/)
- [Github](https://github.com/JDArmy/TextWatermark)
- [Usage](https://textwatermark.jd.army/usage)
- [Example](https://textwatermark.jd.army/example)
- [Changelog](https://textwatermark.jd.army/changelog)
- [API Documents](https://textwatermark.jd.army/api/main/)
- [Templates](https://textwatermark.jd.army/templates/)
- [PyPI](https://pypi.org/project/textwatermark/)

## Requirements

Tested on Python `>= 3.10`

## Installation

### Using Pip

`$ pip install textwatermark`

### From Code

```bash
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

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

Ӏ2𝟑𝟒𝟓Ⳓ𝟟890
```

#### Export watermark parameters

```console
$ 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

```console
$ 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

```py
'''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](https://textwatermark.jd.army/)


            

Raw data

            {
    "_id": null,
    "home_page": "https://textwatermark.jd.army/",
    "name": "textwatermark",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10,<4.0",
    "maintainer_email": "",
    "keywords": "watermark,text,blind",
    "author": "Monyer",
    "author_email": "monyer@126.com",
    "download_url": "https://files.pythonhosted.org/packages/bc/51/601fc9962ea613f14599a32bfcbdea6c48655b69e28f17abd85708ee72a7/textwatermark-0.3.2.tar.gz",
    "platform": null,
    "description": "# TextWatermark\n\nTextWatermark is a library for inserting watermarks into text\n\nPlease take a look at our documentation for how to install and use TextWatermark:\n\n- [Website](https://textwatermark.jd.army/)\n- [Github](https://github.com/JDArmy/TextWatermark)\n- [Usage](https://textwatermark.jd.army/usage)\n- [Example](https://textwatermark.jd.army/example)\n- [Changelog](https://textwatermark.jd.army/changelog)\n- [API Documents](https://textwatermark.jd.army/api/main/)\n- [Templates](https://textwatermark.jd.army/templates/)\n- [PyPI](https://pypi.org/project/textwatermark/)\n\n## Requirements\n\nTested on Python `>= 3.10`\n\n## Installation\n\n### Using Pip\n\n`$ pip install textwatermark`\n\n### From Code\n\n```bash\ngit clone https://github.com/JDArmy/TextWatermark.git\n\ncd TextWatermark\n\npip install .\n\n# or in editable mode\npip install --editable .\n```\n\n## Usage\n\n### CMD Line\n\n#### Insert watermark into text\n\n```console\n$ textwatermark -v insert -f './tests/text/number.txt' -m ALPHA_NUMERICAL -t HOMOGRAPH_NUMBERS -x 999 -w 123\n\n\u04c02\ud835\udfd1\ud835\udfd2\ud835\udfd3\u2cd2\ud835\udfdf890\n```\n\n#### Export watermark parameters\n\n```console\n$ textwatermark -v insert -f './tests/text/number.txt' -m ALPHA_NUMERICAL -t HOMOGRAPH_NUMBERS -x 999 -w 123 -e\n\n{\"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\"}\n```\n\n#### Retrieve the watermark from the text\n\n```console\n$ 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\"}'\n\nThe retrieved watermark is: 123\n```\n\n### Coding\n\n```py\n'''Sample Example'''\nimport os\n\nfrom textwatermark.defines import WMMode\nfrom textwatermark.main import TextWatermark\nfrom textwatermark.template_type import WMTemplateType\n\n# 1.Init TextWatermark instance\nwm_mode = WMMode.REAL_NUMBER\nwm = TextWatermark(wm_mode=wm_mode)\n\n# 2.Choose a watermark template\nwm.set_tpl_type(tpl_type=WMTemplateType.HOMOGRAPH_NUMBERS)\n\n# 3.Set the maximum value of the watermark string\nwm_max = '9'*9\nwm.set_wm_max(wm_max=wm_max)\n\n# 4.Set the text to be watermarked\nwm.set_text_file(path=os.path.abspath('../tests/text/1.txt'))\n\n# 5.Insert watermark string to text\nwm_str = '123456789'\nwm_text = wm.insert_watermark(wm_str=wm_str)\nprint(wm_text)\n\n##############################################################\n\n# Save the parameters to retrieve the watermark\nparams = wm.export_params()\n\n# retrieve the watermark\nwm_out_str = TextWatermark.retrieve_watermark(wm_text=wm_text, params=params)\n\nassert wm_out_str == wm_str\n\n```\n\n## More\n\nSee: [Documents](https://textwatermark.jd.army/)\n\n",
    "bugtrack_url": null,
    "license": "Apache",
    "summary": "A watermark library for text.",
    "version": "0.3.2",
    "split_keywords": [
        "watermark",
        "text",
        "blind"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1eb82bf55a72a347797adf78c504e2d131259531e884f2d8822e6d81bef7d363",
                "md5": "2ef530dc2a7bff2f91868b8d12b65db3",
                "sha256": "d76968ac72bf7652b5d76e9f45e9a915546312f4500f538fef980ff527bcbb89"
            },
            "downloads": -1,
            "filename": "textwatermark-0.3.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2ef530dc2a7bff2f91868b8d12b65db3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10,<4.0",
            "size": 42362,
            "upload_time": "2023-03-15T05:46:38",
            "upload_time_iso_8601": "2023-03-15T05:46:38.841290Z",
            "url": "https://files.pythonhosted.org/packages/1e/b8/2bf55a72a347797adf78c504e2d131259531e884f2d8822e6d81bef7d363/textwatermark-0.3.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bc51601fc9962ea613f14599a32bfcbdea6c48655b69e28f17abd85708ee72a7",
                "md5": "565600047c4141efae4c448c13a98273",
                "sha256": "08e799104ca7dca6a260345b4b0d60c109611b7465dd11c40448db76703b5243"
            },
            "downloads": -1,
            "filename": "textwatermark-0.3.2.tar.gz",
            "has_sig": false,
            "md5_digest": "565600047c4141efae4c448c13a98273",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10,<4.0",
            "size": 34482,
            "upload_time": "2023-03-15T05:46:40",
            "upload_time_iso_8601": "2023-03-15T05:46:40.878874Z",
            "url": "https://files.pythonhosted.org/packages/bc/51/601fc9962ea613f14599a32bfcbdea6c48655b69e28f17abd85708ee72a7/textwatermark-0.3.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-03-15 05:46:40",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "textwatermark"
}
        
Elapsed time: 0.09458s