blind-watermark


Nameblind-watermark JSON
Version 0.4.4 PyPI version JSON
download
home_pagehttps://github.com/guofei9987/blind_watermark
SummaryBlind Watermark in Python
upload_time2023-04-08 14:38:40
maintainer
docs_urlNone
authorGuo Fei
requires_python>=3.5
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            
# blind-watermark

Blind watermark based on dct and svd.


[![PyPI](https://img.shields.io/pypi/v/blind_watermark)](https://pypi.org/project/blind_watermark/)
[![Build Status](https://travis-ci.com/guofei9987/blind_watermark.svg?branch=master)](https://travis-ci.com/guofei9987/blind_watermark)
[![codecov](https://codecov.io/gh/guofei9987/blind_watermark/branch/master/graph/badge.svg)](https://codecov.io/gh/guofei9987/blind_watermark)
[![License](https://img.shields.io/pypi/l/blind_watermark.svg)](https://github.com/guofei9987/blind_watermark/blob/master/LICENSE)
![Python](https://img.shields.io/badge/python->=3.5-green.svg)
![Platform](https://img.shields.io/badge/platform-windows%20|%20linux%20|%20macos-green.svg)
[![stars](https://img.shields.io/github/stars/guofei9987/blind_watermark.svg?style=social)](https://github.com/guofei9987/blind_watermark/)
[![fork](https://img.shields.io/github/forks/guofei9987/blind_watermark?style=social)](https://github.com/guofei9987/blind_watermark/fork)
[![Downloads](https://pepy.tech/badge/blind-watermark)](https://pepy.tech/project/blind-watermark)
[![Discussions](https://img.shields.io/badge/discussions-green.svg)](https://github.com/guofei9987/blind_watermark/discussions)


- **Documentation:** [https://BlindWatermark.github.io/blind_watermark/#/en/](https://BlindWatermark.github.io/blind_watermark/#/en/)
- **文档:** [https://BlindWatermark.github.io/blind_watermark/#/zh/](https://BlindWatermark.github.io/blind_watermark/#/zh/)  
- **中文 readme** [README_cn.md](README_cn.md)
- **Source code:** [https://github.com/guofei9987/blind_watermark](https://github.com/guofei9987/blind_watermark)



# install
```bash
pip install blind-watermark
```

For the current developer version:
```bach
git clone git@github.com:guofei9987/blind_watermark.git
cd blind_watermark
pip install .
```

# How to use


### Use in bash


```bash
# embed watermark into image:
blind_watermark --embed --pwd 1234 examples/pic/ori_img.jpeg "watermark text" examples/output/embedded.png
# extract watermark from image:
blind_watermark --extract --pwd 1234 --wm_shape 111 examples/output/embedded.png
```



## Use in Python

Original Image + Watermark = Watermarked Image

![origin_image](https://blindwatermark.github.io/blind_watermark/原图.jpeg) + '@guofei9987 开源万岁!' = ![打上水印的图](https://blindwatermark.github.io/blind_watermark/打上水印的图.jpg)


See the [codes](/examples/example_str.py)

Embed watermark:
```python
from blind_watermark import WaterMark

bwm1 = WaterMark(password_img=1, password_wm=1)
bwm1.read_img('pic/ori_img.jpg')
wm = '@guofei9987 开源万岁!'
bwm1.read_wm(wm, mode='str')
bwm1.embed('output/embedded.png')
len_wm = len(bwm1.wm_bit)
print('Put down the length of wm_bit {len_wm}'.format(len_wm=len_wm))
```

Extract watermark:
```python
bwm1 = WaterMark(password_img=1, password_wm=1)
wm_extract = bwm1.extract('output/embedded.png', wm_shape=len_wm, mode='str')
print(wm_extract)
```
Output:
>@guofei9987 开源万岁!

### attacks on Watermarked Image


|attack method|image after attack|extracted watermark|
|--|--|--|
|Rotate 45 Degrees|![旋转攻击](https://blindwatermark.github.io/blind_watermark/旋转攻击.jpg)|'@guofei9987 开源万岁!'|
|Random crop|![截屏攻击](https://blindwatermark.github.io/blind_watermark/截屏攻击2_还原.jpg)|'@guofei9987 开源万岁!'|
|Masks| ![多遮挡攻击](https://blindwatermark.github.io/blind_watermark/多遮挡攻击.jpg) |'@guofei9987 开源万岁!'|
|50% Horizontal cut|![横向裁剪攻击](https://blindwatermark.github.io/blind_watermark/横向裁剪攻击_填补.jpg)|'@guofei9987 开源万岁!'|
|50% Vertical cut|![纵向裁剪攻击](https://blindwatermark.github.io/blind_watermark/纵向裁剪攻击_填补.jpg)|'@guofei9987 开源万岁!'|
|Resize 0.5|![缩放攻击](https://blindwatermark.github.io/blind_watermark/缩放攻击.jpg)|'@guofei9987 开源万岁!'|
|Pepper Noise|![椒盐攻击](https://blindwatermark.github.io/blind_watermark/椒盐攻击.jpg)|'@guofei9987 开源万岁!'|
|Brightness 10% Down|![亮度攻击](https://blindwatermark.github.io/blind_watermark/亮度攻击.jpg)|'@guofei9987 开源万岁!'|






### embed images

embed watermark:
```python
from blind_watermark import WaterMark

bwm1 = WaterMark(password_wm=1, password_img=1)
# read original image
bwm1.read_img('pic/ori_img.jpg')
# read watermark
bwm1.read_wm('pic/watermark.png')
# embed
bwm1.embed('output/embedded.png')
```


Extract watermark:
```python
bwm1 = WaterMark(password_wm=1, password_img=1)
# notice that wm_shape is necessary
bwm1.extract(filename='output/embedded.png', wm_shape=(128, 128), out_wm_name='output/extracted.png', )
```


|attack method|image after attack|extracted watermark|
|--|--|--|
|Rotate 45 Degrees|![旋转攻击](https://blindwatermark.github.io/blind_watermark/旋转攻击.jpg)|![](https://blindwatermark.github.io/blind_watermark/旋转攻击_提取水印.png)|
|Random crop|![截屏攻击](https://blindwatermark.github.io/blind_watermark/截屏攻击2_还原.jpg)|![多遮挡_提取水印](https://blindwatermark.github.io/blind_watermark/多遮挡攻击_提取水印.png)|
|Mask| ![多遮挡攻击](https://blindwatermark.github.io/blind_watermark/多遮挡攻击.jpg) |![多遮挡_提取水印](https://blindwatermark.github.io/blind_watermark/多遮挡攻击_提取水印.png)|


### embed array of bits

See it [here](/examples/example_bit.py)


As demo, we embed 6 bytes data:
```python
wm = [True, False, True, True, True, False]
```

Embed:
```python
from blind_watermark import WaterMark

bwm1 = WaterMark(password_img=1, password_wm=1)
bwm1.read_ori_img('pic/ori_img.jpg')
bwm1.read_wm([True, False, True, True, True, False], mode='bit')
bwm1.embed('output/embedded.png')
```

Extract:
```python
bwm1 = WaterMark(password_img=1, password_wm=1, wm_shape=6)
wm_extract = bwm1.extract('output/打上水印的图.png', mode='bit')
print(wm_extract)
```
Notice that `wm_shape` (shape of watermark) is necessary

The output `wm_extract` is an array of float. set a threshold such as 0.5.


# Concurrency

```python
WaterMark(..., processes=None)
```
- `processes`: number of processes, can be integer. Default `None`, meaning use all processes.  

## Related Project

text_blind_watermark: [https://github.com/guofei9987/text_blind_watermark](https://github.com/guofei9987/text_blind_watermark)  
Embed message into text.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/guofei9987/blind_watermark",
    "name": "blind-watermark",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": "",
    "keywords": "",
    "author": "Guo Fei",
    "author_email": "guofei9987@foxmail.com",
    "download_url": "https://files.pythonhosted.org/packages/11/2a/1f209958d9ddf83cb4895132c9329224b96093945e8d3ce331e2064966e0/blind_watermark-0.4.4.tar.gz",
    "platform": "linux",
    "description": "\n# blind-watermark\n\nBlind watermark based on dct and svd.\n\n\n[![PyPI](https://img.shields.io/pypi/v/blind_watermark)](https://pypi.org/project/blind_watermark/)\n[![Build Status](https://travis-ci.com/guofei9987/blind_watermark.svg?branch=master)](https://travis-ci.com/guofei9987/blind_watermark)\n[![codecov](https://codecov.io/gh/guofei9987/blind_watermark/branch/master/graph/badge.svg)](https://codecov.io/gh/guofei9987/blind_watermark)\n[![License](https://img.shields.io/pypi/l/blind_watermark.svg)](https://github.com/guofei9987/blind_watermark/blob/master/LICENSE)\n![Python](https://img.shields.io/badge/python->=3.5-green.svg)\n![Platform](https://img.shields.io/badge/platform-windows%20|%20linux%20|%20macos-green.svg)\n[![stars](https://img.shields.io/github/stars/guofei9987/blind_watermark.svg?style=social)](https://github.com/guofei9987/blind_watermark/)\n[![fork](https://img.shields.io/github/forks/guofei9987/blind_watermark?style=social)](https://github.com/guofei9987/blind_watermark/fork)\n[![Downloads](https://pepy.tech/badge/blind-watermark)](https://pepy.tech/project/blind-watermark)\n[![Discussions](https://img.shields.io/badge/discussions-green.svg)](https://github.com/guofei9987/blind_watermark/discussions)\n\n\n- **Documentation:** [https://BlindWatermark.github.io/blind_watermark/#/en/](https://BlindWatermark.github.io/blind_watermark/#/en/)\n- **\u6587\u6863\uff1a** [https://BlindWatermark.github.io/blind_watermark/#/zh/](https://BlindWatermark.github.io/blind_watermark/#/zh/)  \n- **\u4e2d\u6587 readme** [README_cn.md](README_cn.md)\n- **Source code:** [https://github.com/guofei9987/blind_watermark](https://github.com/guofei9987/blind_watermark)\n\n\n\n# install\n```bash\npip install blind-watermark\n```\n\nFor the current developer version:\n```bach\ngit clone git@github.com:guofei9987/blind_watermark.git\ncd blind_watermark\npip install .\n```\n\n# How to use\n\n\n### Use in bash\n\n\n```bash\n# embed watermark into image:\nblind_watermark --embed --pwd 1234 examples/pic/ori_img.jpeg \"watermark text\" examples/output/embedded.png\n# extract watermark from image:\nblind_watermark --extract --pwd 1234 --wm_shape 111 examples/output/embedded.png\n```\n\n\n\n## Use in Python\n\nOriginal Image + Watermark = Watermarked Image\n\n![origin_image](https://blindwatermark.github.io/blind_watermark/\u539f\u56fe.jpeg) + '@guofei9987 \u5f00\u6e90\u4e07\u5c81\uff01' = ![\u6253\u4e0a\u6c34\u5370\u7684\u56fe](https://blindwatermark.github.io/blind_watermark/\u6253\u4e0a\u6c34\u5370\u7684\u56fe.jpg)\n\n\nSee the [codes](/examples/example_str.py)\n\nEmbed watermark:\n```python\nfrom blind_watermark import WaterMark\n\nbwm1 = WaterMark(password_img=1, password_wm=1)\nbwm1.read_img('pic/ori_img.jpg')\nwm = '@guofei9987 \u5f00\u6e90\u4e07\u5c81\uff01'\nbwm1.read_wm(wm, mode='str')\nbwm1.embed('output/embedded.png')\nlen_wm = len(bwm1.wm_bit)\nprint('Put down the length of wm_bit {len_wm}'.format(len_wm=len_wm))\n```\n\nExtract watermark:\n```python\nbwm1 = WaterMark(password_img=1, password_wm=1)\nwm_extract = bwm1.extract('output/embedded.png', wm_shape=len_wm, mode='str')\nprint(wm_extract)\n```\nOutput:\n>@guofei9987 \u5f00\u6e90\u4e07\u5c81\uff01\n\n### attacks on Watermarked Image\n\n\n|attack method|image after attack|extracted watermark|\n|--|--|--|\n|Rotate 45 Degrees|![\u65cb\u8f6c\u653b\u51fb](https://blindwatermark.github.io/blind_watermark/\u65cb\u8f6c\u653b\u51fb.jpg)|'@guofei9987 \u5f00\u6e90\u4e07\u5c81\uff01'|\n|Random crop|![\u622a\u5c4f\u653b\u51fb](https://blindwatermark.github.io/blind_watermark/\u622a\u5c4f\u653b\u51fb2_\u8fd8\u539f.jpg)|'@guofei9987 \u5f00\u6e90\u4e07\u5c81\uff01'|\n|Masks| ![\u591a\u906e\u6321\u653b\u51fb](https://blindwatermark.github.io/blind_watermark/\u591a\u906e\u6321\u653b\u51fb.jpg) |'@guofei9987 \u5f00\u6e90\u4e07\u5c81\uff01'|\n|50% Horizontal cut|![\u6a2a\u5411\u88c1\u526a\u653b\u51fb](https://blindwatermark.github.io/blind_watermark/\u6a2a\u5411\u88c1\u526a\u653b\u51fb_\u586b\u8865.jpg)|'@guofei9987 \u5f00\u6e90\u4e07\u5c81\uff01'|\n|50% Vertical cut|![\u7eb5\u5411\u88c1\u526a\u653b\u51fb](https://blindwatermark.github.io/blind_watermark/\u7eb5\u5411\u88c1\u526a\u653b\u51fb_\u586b\u8865.jpg)|'@guofei9987 \u5f00\u6e90\u4e07\u5c81\uff01'|\n|Resize 0.5|![\u7f29\u653e\u653b\u51fb](https://blindwatermark.github.io/blind_watermark/\u7f29\u653e\u653b\u51fb.jpg)|'@guofei9987 \u5f00\u6e90\u4e07\u5c81\uff01'|\n|Pepper Noise|![\u6912\u76d0\u653b\u51fb](https://blindwatermark.github.io/blind_watermark/\u6912\u76d0\u653b\u51fb.jpg)|'@guofei9987 \u5f00\u6e90\u4e07\u5c81\uff01'|\n|Brightness 10% Down|![\u4eae\u5ea6\u653b\u51fb](https://blindwatermark.github.io/blind_watermark/\u4eae\u5ea6\u653b\u51fb.jpg)|'@guofei9987 \u5f00\u6e90\u4e07\u5c81\uff01'|\n\n\n\n\n\n\n### embed images\n\nembed watermark:\n```python\nfrom blind_watermark import WaterMark\n\nbwm1 = WaterMark(password_wm=1, password_img=1)\n# read original image\nbwm1.read_img('pic/ori_img.jpg')\n# read watermark\nbwm1.read_wm('pic/watermark.png')\n# embed\nbwm1.embed('output/embedded.png')\n```\n\n\nExtract watermark:\n```python\nbwm1 = WaterMark(password_wm=1, password_img=1)\n# notice that wm_shape is necessary\nbwm1.extract(filename='output/embedded.png', wm_shape=(128, 128), out_wm_name='output/extracted.png', )\n```\n\n\n|attack method|image after attack|extracted watermark|\n|--|--|--|\n|Rotate 45 Degrees|![\u65cb\u8f6c\u653b\u51fb](https://blindwatermark.github.io/blind_watermark/\u65cb\u8f6c\u653b\u51fb.jpg)|![](https://blindwatermark.github.io/blind_watermark/\u65cb\u8f6c\u653b\u51fb_\u63d0\u53d6\u6c34\u5370.png)|\n|Random crop|![\u622a\u5c4f\u653b\u51fb](https://blindwatermark.github.io/blind_watermark/\u622a\u5c4f\u653b\u51fb2_\u8fd8\u539f.jpg)|![\u591a\u906e\u6321_\u63d0\u53d6\u6c34\u5370](https://blindwatermark.github.io/blind_watermark/\u591a\u906e\u6321\u653b\u51fb_\u63d0\u53d6\u6c34\u5370.png)|\n|Mask| ![\u591a\u906e\u6321\u653b\u51fb](https://blindwatermark.github.io/blind_watermark/\u591a\u906e\u6321\u653b\u51fb.jpg) |![\u591a\u906e\u6321_\u63d0\u53d6\u6c34\u5370](https://blindwatermark.github.io/blind_watermark/\u591a\u906e\u6321\u653b\u51fb_\u63d0\u53d6\u6c34\u5370.png)|\n\n\n### embed array of bits\n\nSee it [here](/examples/example_bit.py)\n\n\nAs demo, we embed 6 bytes data:\n```python\nwm = [True, False, True, True, True, False]\n```\n\nEmbed:\n```python\nfrom blind_watermark import WaterMark\n\nbwm1 = WaterMark(password_img=1, password_wm=1)\nbwm1.read_ori_img('pic/ori_img.jpg')\nbwm1.read_wm([True, False, True, True, True, False], mode='bit')\nbwm1.embed('output/embedded.png')\n```\n\nExtract:\n```python\nbwm1 = WaterMark(password_img=1, password_wm=1, wm_shape=6)\nwm_extract = bwm1.extract('output/\u6253\u4e0a\u6c34\u5370\u7684\u56fe.png', mode='bit')\nprint(wm_extract)\n```\nNotice that `wm_shape` (shape of watermark) is necessary\n\nThe output `wm_extract` is an array of float. set a threshold such as 0.5.\n\n\n# Concurrency\n\n```python\nWaterMark(..., processes=None)\n```\n- `processes`: number of processes, can be integer. Default `None`, meaning use all processes.  \n\n## Related Project\n\ntext_blind_watermark: [https://github.com/guofei9987/text_blind_watermark](https://github.com/guofei9987/text_blind_watermark)  \nEmbed message into text.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Blind Watermark in Python",
    "version": "0.4.4",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "490e566fcbff9284c058c048207b46aed3645adeb4d6fb1e514fa4ad2653930f",
                "md5": "b635c51df7278894970b4534e400fd6d",
                "sha256": "eb7a9587b3c682f4fc8a8f8a0b728668931bca18e580a7de70e134088764aede"
            },
            "downloads": -1,
            "filename": "blind_watermark-0.4.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b635c51df7278894970b4534e400fd6d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.5",
            "size": 14562,
            "upload_time": "2023-04-08T14:38:37",
            "upload_time_iso_8601": "2023-04-08T14:38:37.913069Z",
            "url": "https://files.pythonhosted.org/packages/49/0e/566fcbff9284c058c048207b46aed3645adeb4d6fb1e514fa4ad2653930f/blind_watermark-0.4.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "112a1f209958d9ddf83cb4895132c9329224b96093945e8d3ce331e2064966e0",
                "md5": "071e7aa1ce6e253fb245df3890380d7e",
                "sha256": "04c976a7a8d2031a754048e1181a75410b66b98a9941468365bee4aa733a996e"
            },
            "downloads": -1,
            "filename": "blind_watermark-0.4.4.tar.gz",
            "has_sig": false,
            "md5_digest": "071e7aa1ce6e253fb245df3890380d7e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5",
            "size": 14062,
            "upload_time": "2023-04-08T14:38:40",
            "upload_time_iso_8601": "2023-04-08T14:38:40.044982Z",
            "url": "https://files.pythonhosted.org/packages/11/2a/1f209958d9ddf83cb4895132c9329224b96093945e8d3ce331e2064966e0/blind_watermark-0.4.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-08 14:38:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "guofei9987",
    "github_project": "blind_watermark",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "blind-watermark"
}
        
Elapsed time: 0.08313s