Do you want to protect your pictures? Or do you want to include information into your pictures (e.g. to who it was delivered)? Then this library is designed right for you! Currently visible and LSB watermark methods are supported. You can also add your own protection methods.
IMPORTANT: this project is in early stage and it might change a lot.
Project follows SemVer specification.
Download/clone repository from GitHub.
Library requires Python 2.6/2.7/3.x. You can build it with command:
python setup.py build
For development, you might also find usefull 3rd party libs from requirements.txt. Install them with command:
pip install -r requirements.txt
You can test Watermarks by calling selftest() function:
>>> from watermarks.selftest import selftest
>>> selftest()
True
However, the pillow dependency might need some other libraries to work properly. If you meet error message like IOError: decoder zip not available, please install following libs:
CentOS:
yum install freetype freetype-devel libpng libpng-devel libjpeg libjpeg-devel
Ubuntu:
apt-get install python-dev
or:
apt-get install python-dev3
and:
apt-get install python-setuptools libtiff4-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.5-dev tk8.5-dev python-tk
Then reinstall the pillow dependency:
pip uninstall pillow
pip install -r requirements.txt
If it is still not running, please visit pillow’s documentation for more installation help.
There are few different ways to run Watermarks:
Executable:
(e) $ wm-reader lsb -d tmp test/data/shape1-rgb-l0.png
Loader:
from watermarks.core.loader import Loader
r = Loader('readers')
r.run(args)
Init:
from watermarks.core.readers.lsb import init
lsb = init(args)
lsb.run(['test/data/shape1-rgb-l0.png'])
Directly:
from watermarks.core.readers.lsb import Lsb
lsb = Lsb(destination='tmp', format='png')
lsb.run(['test/data/shape1-rgb-l0.png'])
There is possibility to read/write multiple watermarks in one go. To do so, pass more methods separated with comma. In wm-writer you must also pass appropriate number of watermarks. Example:
wm-writer lsb,visible -w test/data/gen-wmode-wm-rgb.png -w test/data/gen-wmode-wm-l.png -d tmp test/data/shape1-rgb-l0.png
Methods will be applied in order they were specified.
.. is as easy as:
$ tox
or:
$ PYTHONPATH=src nosetests --with-coverage --cover-erase --cover-package=watermarks.core test/functiontests/
Lsb (least significant bit) is method that extracts least significat (last) bit from every subpixel and generates image - black pixel for subpixels ending with 0 (even) and white pixel for subpixels ending with 1 (odd). For writing LSB watermark into image, Watermarks modifies least significant bit of every subpixel in image.
For more information use Google :)
original image | watermarked image |
---|---|
Can you see the difference? No? So let’s use Watermarks to extract last bit and generate image:
red band (last bit) | red band (last bit) |
---|---|
You are allowed to use custom watermark methods. When running from binary, just pass your custom watermark method via argument. (If WM does not find method in it’s built-in methods then it will try to find it in $PYTHONPATH.)
Module with custom method must have functions init(args), update_parser(parser) and method implementation class with function run(). Please see some existing method (in watermarks.core.[readers|writers]) for example.