Invisible Digital Watermarking in Python

Adding a watermark to the image/screenshot/video is a commonly used way for copyright protection. (see Wiki for more details).

Sometimes even though the watermark is added, they can be easily photoshoped or simply cropped. Thus “Invisible Digital Watermarking” is introduced in order to better hide the watermark. See Steganography Wiki for more infomation about hiding information within another object. Tencent Cloud also has this “Blind watermarking” API.

As an amateur artist, I also have the need to add my own watermark to my work while maintaining overall good image quality.

An invisible watermark generating website: https://invisiblewatermark.net/ and see how it works.

When comparing the watermarked image and the retrieved watermark:

However, this website can only add text watermarks. Also when the image was cropped, the retrieved watermark is (almost) gone:

I am totally new to image processing /Cryptography, so I will be using another open source project that I found in GitHub as an example for invisible digital watermarking in Python.

GitHub reference:https://github.com/guofei9987/blind_watermark and many thanks to the original contributor(s).

It can add text, image and array of bits as hidden watermark to the image, and it also has pretty good anti-attack capabilities. See the documentation for more details.

Now I will use the same cat image that I took today for testing, and I personally prefer the image watermark.

Run the example_img.py, and the wm_extracted.png is the watermark that was retrieved:

Comparing the image watermark after/ before:

Comparing the output/original image:

From my previous tests, the size of the image watermark(<12KB) will affect the output image’s quality. Also the size of the image went from 991KB to 2.71MB, which is quite surprising…

Remember to change the wm setting in the last line, otherwise you won’t get the watermark and it would only go static:

#change wm_shape here!
bwm1.extract('output/embedded.png', wm_shape=(96, 96), out_wm_name='output/wm_extracted.png', )

That’s it. Give it a try!

Leave a Reply

Your email address will not be published. Required fields are marked *