Skip to main content

About this fork

This is a full unchanged clone of the repository at https://github.com/originell/sorl-watermark

I can't install the original package in docker container from Github, only from Pypi. Well, I could do it, but I would have to install git into my container, but I want to keep it as small as possible. The original project at https://pypi.org/project/sorl-watermark/ is outdated, so I forked and published the latest version on Pypi under the new name sorl-wmark, and you can install it with

$ pip install sorl-wmark

sorl-watermark

sorl-watermark adds support for watermarking to sorl-thumbnail.

Supports:

  • Django 1.3+ (tested with Django 1.10.4 up to 2.1)
  • Sorl-Thumbnail 11+ (tested with 12.4a1 to 12.5.0)
  • Pillow 3+ (tested with 3, 4.2 and 5)
  • Python 2.7 to 3.7

Of course everything is configurable, from the watermark image to position and opacity.

If you are looking for a sorl engine to dynamically create text watermarks, you might want to have a look at zeus/watermark.

Setup

Install via pip

$ pip install sorl-wmark

Change sorl's thumbnail engine to one from sorl-watermark. PIL and imagemagick are supported.

PIL:

# PIL is the most well tested backend.
THUMBNAIL_ENGINE = 'sorl_watermarker.engines.pil_engine.Engine'

Pgmagick:

# PIL is the most well tested backend.
THUMBNAIL_ENGINE = 'sorl_watermarker.engines.pgmagick_engine.Engine'

Next up, you tell it which image should be used as a watermark. Note that this file has to live somewhere inside STATIC_ROOT.

THUMBNAIL_WATERMARK = 'my_watermark.png'

That's it for a simple setup. The engine will only apply the watermark if the thumbnail size is big enough.

See Advanced Usage for ways to dynamically change the watermark itself, it's size or ways to selectively apply watermarks.

Advanced Usage

sorl-watermark adds additional options to the {% thumbnail %} templatetag.

The following new options are available:

  • watermark=imagefile This options takes an ImageFile and uses this one instead of the default watermark file, set via THUMBNAIL_WATERMARK
  • watermark_size="x200" Changes the watermark's size. Takes the same options as the THUMBNAIL_WATERMARK_SIZE option.
  • watermark_pos="north east" Specifies where the watermark shall be put. Accepts the same options as the THUMBNAIL_WATERMARK_POSITION setting.
  • watermark_alpha=0.9 Sets the watermark's opacity. Has to be a value between 0 and 1.

Settings Reference

The following settings are available

  • THUMBNAIL_WATERMARK Sets the image to be used as a watermark. The file must live within STATIC_ROOT.

  • THUMBNAIL_WATERMARK_ALWAYS Stamp a watermark on every image. Default is True.

  • THUMBNAIL_WATERMARK_SIZE Change the size of the watermark. This can either be a geometry string, as is usual with sorl-thumbnail ("x200", "200x200"), or a percentage. If given a percentage, the watermark will always be the given percentage of the thumbnail size.

  • THUMBNAIL_WATERMARK_OPACITY An integer from 0 to 1, specifying the opacity of the watermark. Default is 0 (opaque).

  • THUMBNAIL_WATERMARK_POSITION Specifies the position of the watermark. You can specify the position with a pair of padding values (in pixels) Ex. "20 20" will place watermark near the left-top corner, "-20 -20" - near the right-bottom corner. Either you can specify the position as:

    • "north"
    • "south"
    • "west"
    • "east"
    • "north east"
    • "south east"
    • "north west"
    • "south west"
    • "center"

    Default: "south east" (right-bottom corner)

    If you want to tile your image completely with a watermark, you should set:

    THUMBNAIL_WATERMARK_POSITION = 'tile'
    

Release files for sorl-wmark 1.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for sorl-wmark 1.1.1
File Interpreter ABI Platform
sorl_wmark-1.1.1-py3-none-any.whl Python 3 none any Details

Release files / sorl_wmark-1.1.1-py3-none-any.whl

Download URL sorl_wmark-1.1.1-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dcb1703a8e4b44a089c7d877ad7eba6b517dd5f588e6da28579f4ec8cded033f
BLAKE2b-256 checksum
How to use checksums
b7438c1e0e4149c839c98da8f3eef9693ae960d17d3b777baad8328ad8ab7d21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.50.0 CPython/3.8.2

Release history Release notifications | RSS feed

This release

1.1.1 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page