This issue recommends blind_watermark, a Python library for embedding blind watermarks in images.
Blind watermarking is that the image has a watermark but the human eye can not see it, and the watermark needs to be extracted through the program, which is equivalent to invisible “stamp”, and can be used in data leak traceability, copyright protection and other scenes. blind_watermark currently supports embedding images, strings, and binary.
Installation:
install with pip install:
pip install blind-watermark
Or install the latest development version:
git clone git@github.com:guofei9987/blind_watermark.gitcd blind_watermarkpip install
Example of use:
Embedded image watermarking
from blind_watermark import WaterMarkbwm1 = WaterMark(password_wm=1, password_img=1)# Read artwork bwm1.read_img('pic/ori_img.jpg')# Read watermark bwm1.read_wm('pic/watermark.png')# Put a blind watermark bwm1.embed('output/Put a blind watermark.png')
Extract image watermark
bwm1 = WaterMark(password_wm=1, password_img=1)# Note You need to set the length and width of the watermark wm_shapebwm1.extract(filename='output/Put a blind watermark .png', wm_shape=(128, 128), out_wm_name='output/Put a blind watermark.png', )
Embedded string
from blind_watermark import WaterMarkbwm1 = WaterMark(password_img=1, password_wm=1)bwm1.read_img('pic/ori_img.jpg')wm = '@guofei9987 Put a blind watermark !'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
bwm1 = WaterMark(password_img=1, password_wm=1)wm_extract = bwm1.extract('output/embedded.png', wm_shape=len_wm, mode='str')print(wm_extract)
Effect display:
Master drawing
Do various attacks on the graph after embedding the blind watermark
You can read more on your own.