Welcome to Watermarks’ documentation!

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.

Installation

pip

Just type command:

pip install watermarks

From source code

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.

Usage

There are few different ways to run Watermarks:

  • executables wm-reader and wm-writer
  • using watermarks.core.loader.Loader to load and run method
  • using method’s init function, e.g. watermarks.core.writers.lsb.init
  • make method instance (e.g. watermarks.core.writers.lsb.Lsb) by yourself

Examples

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'])

Methods chaining

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.

Running tests

.. is as easy as:

$ tox

or:

$ PYTHONPATH=src nosetests --with-coverage --cover-erase --cover-package=watermarks.core test/functiontests/

Methods

LSB

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 :)

Example

original image watermarked image
_images/sample.png _images/sample_watermarked.png

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)
_images/sample_R.png _images/sample_watermarked_R.png

Custom methods

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.

Release notes

0.4 (01.09.2014)

  • add position argument with restricted values
  • rename executables wm_reader/wm_writer to wm-reader/wm-writer
  • make destination format same as input (by default)
  • write watermark only to specified bands
  • read only specified bands

0.3 (01.07.2014)

  • read/write multiple watermarks (like in chain)
  • custom help for methods
  • added arg –version
  • switch to latest pillow (2.4.0)
  • lot of new tests

0.2 (01.06.2014)

  • possibility to set watermark’s position (topleft, center, ...)
  • executables part of pip installation
  • new arguments quiet/verbose, suffix and position
  • each method can now have it’s own extra command line arguments
  • create destination directory if it does not exists
  • use tox to test this library
  • BaseMethod class for easier development of custom methods
  • requirements split for users and developers (no need to install libs you do not need)

0.1.1 (01.05.2014)

  • fix crash when processing unsupported file format/mode
  • improved installation process
  • improved Python3 support
  • various small fixes

0.1 (23.04.2014)

  • very first version of Watermarks
  • support for lsb reading/writing
  • support for writing visible watermarks
  • support for user defined watermark methods
  • bunch of analyze tools
  • runs with Python 2.6, 2.7, 3.x

Indices and tables