Image Watermarking

From CollectiveAccess Documentation
Jump to: navigation, search

Watermarking of images

CollectiveAccess can automatically add a visible watermark to image derivatives. The watermark pattern is a graphic provided by you: it can be a logo, text or anything else than can be expressed in a bitmap. Watermarking is applied as derivatives are created. The watermarks are part of the image and cannot be easily removed. (They can be cropped out or Photoshop'ed away, of course, just like anything else in an image).


Watermarking is only supported for image formats processed by the ImageMagick and IMagick media processing plugins. Watermarking is not supported with GD. If you are having trouble getting watermarking to work make sure your system is actually using ImageMagick/IMagick.

Getting started

Watermarking works by superimposing your watermark image over the image being processed. You can specify the location, size and transparency for the watermark, which gives you some control over how obviously visible the watermark is. If you need to mark images in a way that is detectable but not distracting then a small mostly transparent logo in a corner of the image is probably sufficient. If you want to render images completely unusable for anything but sample purposes a relatively opaque watermark the size of the image itself may be called for.

How the watermark image is defined will greatly affect how well it performs. An effective watermark will be detectable no matter what the image it sits on looks like. As you can imagine, if your watermark image is black text and you superimpose it on a dark region it won't be very noticeable. In practice, simple black text or logo watermarks will be virtually undetectable to all viewer, including you, on dark backgrounds.

To ensure visibility on all backgrounds make sure your watermark image contains both black and white. One effective technique is to take a simple black outline of text or a logo (or both) and give it a white "halo." If you have access to Photoshop you can do this easily by:

  1. Open the original outline in Photoshop and select only the content (ie. create a selection that includes only the text or logo, not the white background)/
  2. Copy and paste the selection into a new layer behind the original one.
  3. Invert the new layer so what was black is now white.
  4. Move the new layer down 1 or 2 pixels and to the left 1 or two pixels. (Vary the movement amount and directions to suit your taste).
  5. Save this resulting image as a JPG, PNG or TIFF.


Once you have your watermark image ready, the next step is to configure CollectiveAccess to use it. To do so you must media the media_processing.conf configuration file in app/conf.

You can add watermarking to specific derivatives (or "versions" as they are referred to in the configuration file) by adding a WATERMARK rule to their processing rules.

The WATERMARK rule takes the following parameters:

Parameter Description Possible values Default
image Absolute path to your watermark image Note that this MUST be the absolute path to the watermark image. If you put it in your 'app' directory you can use preexisting macros set in global.conf, such as <ca_app_dir>, to avoid hardcoding in path info. Eg. if you have the watermark image at /web/ca/app/watermarks/mymark.png you can configure it here as <ca_app_dir>/watermarks/mymark.png None; this must be defined
width Width of watermark in pixels 50% of the width of the image being processed
height Height of watermark in pixels 50% of the height of the image being processed
position Location of watermark on processed image; allowable values will place the watermark on the corners (eg. "north_west" is the upper-left-hand corner), the center on top or bottom ("north" or "south") or in the center of the image ("center") north_east, north_west, north, south_east, south_west, south, center south_west
opacity Determines transparency of watermark image Use a value between 0 and 1. 0=completely transparent; 1.0=completely opaque 0.5

You should add WATERMARK rule with the appropriate values to each version you want to watermark. A watermark configuration for the "small" version (default 240x240 pixel image) might look like this:

rule_small_image = {
    SCALE = {
         width = 240, height = 240, mode = bounding_box, antialiasing = 0.5
         image = <ca_app_dir>/watermarks/my_watermark_logo.png,
         width = 72, height = 85, position = south_east, opacity = 0.4
    SET = {quality = 75, format = image/jpeg}

The non-WATERMARK rules are just the default rules; only WATERMARK is new. The configuration above assumes that your my_watermark_logo.png image file is located in a directory called watermarks in the CA app/ directory.

Note: WATERMARKing is not applied to tilepic version of the images, since this is a format not easy to be 'stolen' in itself.



Personal tools