Image scaling and watermarking
This step plugin scales images to configurable maximum sizes and renders a watermark into the scaled images.

Introduction

This plugin allows you to scale images to a maximum size and then render watermarks into the previously scaled images. The maximum size and the watermark to be rendered can be configured flexibly.

Overview

Details
Text
Identifier
intranda_step_image_resize_and_watermark
Licence
GPL 2.0 or newer
Compatibility
Goobi workflow 2020.06
Documentation date
31.08.2020

Installation

To install the plugin, the following file must be installed:
1
/opt/digiverso/goobi/plugins/step/plugin_intranda_step_image_resize_and_watermark.jar
Copied!
A configuration file is also required to run the plugin correctly:
1
/opt/digiverso/goobi/config/plugin_intranda_step_image_resize_and_watermark.xml
Copied!
Furthermore, a successful installation of the following two packages is also required on the system:
1
ImageMagick
2
GraphicsMagick
Copied!
Both packages are included in common package managers and can be easily installed from them.

Configuration of the plugin

The configuration of the plugin allows you to define the maximum size of the images and the watermark (images and text watermarks are supported). Also the positioning of the watermark can be defined individually. Several configurations are possible for this purpose, which are differentiated by the project, the name for the work step within the workflow, the digital collection as well as a media type (special metadata within the METS file of the respective process). When the plugin is executed, the first configuration that matches the currently processed task is used.
Please note that the correct paths for GraphicMagick and ImageMagick must also be specified at the top of the configuration.
An example configuration for the file plugin_intranda_step_image_resize_and_watermark.xml looks like this:
1
<config_plugin>
2
<!-- path to GraphicsMagick -->
3
<gmPath>/usr/bin/gm</gmPath>
4
<!-- path to ImageMagick -->
5
<convertPath>/usr/bin/convert</convertPath>
6
<!--
7
order of configuration is:
8
1.) project name and step name matches
9
2.) step name matches and project is *
10
3.) project name matches and step name is *
11
4.) project name and step name are *
12
-->
13
<config>
14
<!-- which projects to use for (can be more than one, otherwise use *) -->
15
<project>*</project>
16
<step>*</step>
17
18
<!-- the source directory from which the images will be taken -->
19
<sourceDir>cropped</sourceDir>
20
<!-- the destination directory where the scaled and watermarked images will reside -->
21
<destDir>media</destDir>
22
23
<!-- only use this block with processes in collection "mycollection"
24
and with mediaType "book" -->
25
<imageConfig collection="mycollection" mediaType="book">
26
<!-- The maximum size of the longest side of an image -->
27
<resizeTo>1500</resizeTo>
28
<!-- The watermark configuration -->
29
<watermark>
30
<!-- the image to use for watermarking -->
31
<image>/opt/digiverso/goobi/xslt/logo.png</image>
32
<!-- define the shade size here -->
33
<shadeSize>240x40</shadeSize>
34
<!-- the location of the watermark. Possible values: north,
35
northeast, east, southeast, south, southwest,
36
west, northwest -->
37
<location>southeast</location>
38
<!-- these are the distances to the edges on the x- resp. y-axis -->
39
<xDistance>100</xDistance>
40
<yDistance>100</yDistance>
41
</watermark>
42
</imageConfig>
43
44
<!-- use this block with processes in collection "myothercollection"
45
and any mediaType -->
46
<imageConfig collection="myothercollection" mediaType="*">
47
<resizeTo>1500</resizeTo>
48
<watermark>
49
<!-- you can also use a text-only watermark. -->
50
<text>My watermark text</text>
51
<!-- define the shade size here -->
52
<shadeSize>240x40</shadeSize>
53
<!-- define the size of the box for the text -->
54
<boxSize>450x200</boxSize>
55
<!-- font to use for the text rendering -->
56
<font>Open-Sans</font>
57
<location>southeast</location>
58
<xDistance>600</xDistance>
59
<yDistance>100</yDistance>
60
</watermark>
61
</imageConfig>
62
63
</config>
64
</config_plugin>
Copied!
The block <config> can occur repeatedly for different projects or workflow steps in order to be able to carry out different actions within different workflows. The other parameters within this configuration file have the following meanings:
Value
Description
gmPath
Path to install GraphicsMagick
convertPath
Path to install ImageMagick
project
This parameter defines the project for which the current block <config> is to apply. The name of the project is used here. This parameter can occur several times per <config> block.
step
This parameter controls for which work steps the block <config> is to apply. The name of the work step is used here. This parameter can occur several times per <config> block.
sourceDir
Path to the directory to be used as the source directory.
destDir
Path to the directory in which the scaled and watermarked images are to be saved.
mediaType
Restriction to operations whose metadata of type Type corresponds to the configured value. Alternatively, * can be used to make no restriction.
collection
Restriction to the operations that belong to a selected digital collection.
resizeTo
Maximum size of the image on the longest side. Specified in pixels.
watermark/image
Path to an image to be used within the watermark.
watermark/shadeSize
Define here which size specification should be used as shade.
watermark/text
Text to be used within the watermark.
watermark/font
Specify here which font should be used for the text. This font must be installed on the system.
watermark/boxSize
Define here what dimensions the box should have within which the text is to be rendered. This thus determines the size of the displayed font.
watermark/location
Determines where within the image the watermark should be rendered. Possible specifications are north, northeast, east, southeast, south, southwest, west, northwest
watermark/xDistance
Lateral distance of the watermark
watermark/yDistance
Distance of the watermark up or down

Integration of the plugin into the workflow

To use the plug-in, it must be activated for one or more desired tasks in the workflow. This is done by selecting the plugin intranda_step_image_resize_and_watermark from the list of installed plugins.
Integration of the plugin into the workflow
After running the plugin the images have the expected size and have the configured watermark.
Possible results in the generated images