Introduction

The endpoint of this service allows to download images with some transformations.

Configuration

Each action is associated to an identifier and a JSON configuration.

JSON example

{
  "objectname": "name of the object",
  "description": "description of action",
  "prop": "name of property",
  "preset": "name of preset"
  "command": { definition of command set }
}

Properties and sections

EndPoints

There are two endpoints available:

EndPoint: Transform and download an image

GET http://host:port/app/api/json/imaging/{actionName}/{id}{/transform}

GET http://host:port/app/api/json/imaging

Legacy endpoint:

http://host:port/app/_plugins/WXM_RESTAPI/page/imaging.jspz

Supported methods: GET, HEAD

Parameters

Response format

The transformed image is returned in the body, as attachment. The response contains the following specific header:

Security

The imageprocessing action of the RESTAPI domain allows the management of endpoint call authorisation. Its unique parameter is actionName, the action identifier.

Error codes

HTTP Code

API Code

Definition

404

404/1100

Unknown action

403

403/1100

Unreachable action (or forbidden)

422

422/1100

Unreachable action (configuration problem)

422

422/1101

Resource not found

403

403/1102

Forbidden action

500

500/1100

Internal server error (error with command, preset or image file…​)

EndPoint: available action list

GET http://host:port/app/api/json/catalog/imaging

Legacy endpoint:

http//host:port/app/_plugins/WXM_RESTAPI/page/catalog/imaging.jspz

Supported methods: GET, HEAD

Parameters

Response format

{
  "catalog": "list of image processing actions",
  "response": {
    "data": [ {
      "name": "name of the action",
      "description": "description of the action",
      "preset": "name of preset"
      "command": { description of command }
      }
    }
    ]
  },
  "links": {
    "href": "http://host:port/app/_plugins/WXM_RESTAPI/page/catalog/imaging.jspz"
  },
  "status": 200,
  "time": 29
}

Security

The catalog action of RESTAPI domain allows the management of the endpoint call authorisation. Its unique parameter is endPoint, with a imageprocessing value.

Error codes

HTTP Code

API Code

Definition

403

403/601

Unreachable catalog (or forbidden)

Command set

Introduction

A command set is a list of commands that will be executed one after the other on the image. There are three different forms of syntaxes:

A command set can be configured as an object, where each property is a command name. As the JSON syntax doesn’t allows to have several properties with the same name, you can use an array of objects (JSON object with command property, JSON array with command name as first item, or object with a single property) .

Example of object command set:

{
  "resize": [100,-1],
  "format": "png"
}

Example of array command set:

[
  {
   "command":"crop",
   "width":100
  },
  ["preset","identifierOfPreset"],
  {
    "resize": {"width":"50%","height":"50%"}
  }
]

commenting commands

A command can be temporarily disabled by commenting its name: just prefix the name with the dollar character ($).

{
  "resize": [100,-1],
  "$format_cpl20180812": "jpg",
  "format": "png"
}

To comment a command in simplified syntax, take care to put the $ at the beginning of the name of command, not before the prefix, like this by example: w_100,h_100,c_resize,e_png,c_$format. The command and all its parameters are skipped in that case.

short syntax versus full syntax

Example of shorten syntax (array) command:

"resize": [100,-1],

Example of full syntax command:

"resize": {
   "width":100,
   "height":"proportional"
}

The array syntax is shorter, but you’ll have to care of the order of parameters, and sometimes some ambiguities will force you to use the full syntax. Note that full syntax allows some default values for missing parameters that cannot be handled in short syntax.

the simplified syntax

This syntax does not use JSON syntax. The command set is defined by a comma separated list of parameters:

This kind of parameters are boolean switches. By default, the value is true. The prefix - set it to false and the prefix + explicitly set it to true.

Each command is preceded by its parameters.

Example:

w_100,h_100,c_resize

Simple text (without spaces or special characters) can be specify also:

tx_hello

To specify text with spaces, or other special characters, embrace it between double-quotes:

tx_"hello you!"

You can put double-quotes within text by duplicate them:

tx_"say ""hello""!"

Use antislash \ to escape special characters, like \n for carriage return. Use two of them to get an antislash: \\n means exactly \n, not carriage return.

tx_"First line\nSecond line: \\n"

(the text will be:

first line
second line: \n

)

You can use \u followed by unicode codepoint (four hexadecimal digits mandatory) to specify special characters:

tx_"\u00a9xxx"

(the text will be: ©xxx)

Spaces are not allowed in shorten syntax, except within texts.

values

Except for switches, the values for the parameters are the same for all syntaxes. For switches, in full syntax, use the values true or false, and in short syntax, only the name of the switch.

By example, these three syntaxes mean the same:

t_10%,+fixed,c_crop
"crop": ["fixed","10%"]
"crop": {
         "fixed":true,
         "top":"10%"
        }

dimension value

Defines a dimension (x, y, width, height, top, right, bottom or left) in pixels. It could be absolute or relative to the size of the image.

size value

Defines a dimension in different units. The same values as used for dimension value could be used, and the followed additional syntaxes:

factor value

Defines a factor.

angle value

Defines an angle value, in degrees by default.

boolean value

Defines a boolean. Value can be true or false (JSON boolean or string).

"fixed": true,
"centered": "false"

color value

Defines a color, with

font description

Defines a font, with a font name (a string), a font size (cf "size value"), font styles (bold, italic…​).

Font styles are a combination of different parameters:

When the font size is relative (to the height of image, in percent, or fraction), the pointsize is computed taking into account a default standard resolution of 96 DPI. It’s possible to be take into account the resolution of the image (yDPI) with the parameter (or switch) tiad.

text decoration parameter

Specifies a text decoration, one of these values:

gravity value

Specifies a location in the image, like in this grid:

northwest

north

northeast

west

center

east

southwest

south

southeast

Gravity often can be mixed with a location by coordinates (x and y):

preset value

Designates a preset name (cf presets documentation)

shade parameters

It’s two positive integers (angles in degrees) separated with an x. The first is direction and the second elevation, of a light source.

"shade": "45x90"

string value

A simple text or word

"text": "hello!"

text color parameters:

It consists of several parameters to colorize a text:

The text color parameters can be configured as

fixed size parameter

A boolean or a couple of dimension values. Values can be:

overlay parameter

Used to configure an overlay for watermarking

colorization

A color blending factor (in percent from 1 to 100), or an array of three factors, one for each color channel (red, green and blue), or a string that contains the triplet like 50,25,70 or 50|25|70.

commands

simplified command shortcuts

Some commands have shortcuts in simplified syntax. The command name is useless in a shortcut, but it is not possible to chain several commands.

crop

format

rescale

resize

rotate

watermark

Available fill patterns

Value

Description

Notes

BRICKS

brick pattern, 16×16

bricks

CHECKERBOARD

checkerboard, 30×30

checkerboard

CIRCLES

circles pattern, 16×16

circles

CROSSHATCH

crosshatch pattern, 8×4

crosshatch

CROSSHATCH30

crosshatch pattern with lines at 30 degrees, 8×4

crosshatch30

CROSSHATCH45

crosshatch pattern with lines at 45 degrees, 8×4

crosshatch45

FISHSCALES

fish scales pattern, 16×8

fishscales

GRAY0

0% intensity gray, 32×32

gray0

GRAY5

5% intensity gray, 32×32

gray5

GRAY10

10% intensity gray, 32×32

gray10

GRAY15

15% intensity gray, 32×32

gray15

GRAY20

20% intensity gray, 32×32

gray20

GRAY25

25% intensity gray, 32×32

gray25

GRAY30

30% intensity gray, 32×32

gray30

GRAY35

35% intensity gray, 32×32

gray35

GRAY40

40% intensity gray, 32×32

gray40

GRAY45

45% intensity gray, 32×32

gray45

GRAY50

50% intensity gray, 32×32

gray50

GRAY55

55% intensity gray, 32×32

gray55

GRAY60

60% intensity gray, 32×32

gray60

GRAY65

65% intensity gray, 32×32

gray65

GRAY70

70% intensity gray, 32×32

gray70

GRAY75

75% intensity gray, 32×32

gray75

GRAY80

80% intensity gray, 32×32

gray80

GRAY85

85% intensity gray, 32×32

gray85

GRAY90

90% intensity gray, 32×32

gray90

GRAY95

95% intensity gray, 32×32

gray95

GRAY100

100% intensity gray, 32×32

gray100

HEXAGONS

hexagon pattern, 30×18

hexagons

HORIZONTAL

horizontal line pattern, 8×4

horizontal

HORIZONTAL2

horizontal line pattern, 8×8

horizontal2

HORIZONTAL3

horizontal line pattern, 9×9

horizontal3

HORIZONTALSAW

horizontal saw-tooth pattern, 16×8

horizontalsaw

HS_BDIAGONAL

backward diagonal line pattern (45 degrees slope), 8×8

hs bdiagonal

HS_CROSS

cross line pattern, 8×8

hs cross

HS_DIAGCROSS

diagonal line cross pattern (45 degrees slope), 8×8

hs diagcross

HS_FDIAGONAL

forward diagonal line pattern (45 degrees slope), 8×8

hs fdiagonal

HS_HORIZONTAL

horizontal line pattern, 8×8

hs horizontal

HS_VERTICAL

vertical line pattern, 8×8

hs vertical

LEFT30

forward diagonal pattern (30 degrees slope), 8×4

left30

LEFT45

forward diagonal pattern (45 degrees slope), 8×8

left45

LEFTSHINGLE

left shingle pattern, 24×24

leftshingle

OCTAGONS

octagons pattern, 16×16

octagons

RIGHT30

backward diagonal line pattern (30 degrees), 8×4

right30

RIGHT45

backward diagonal line pattern (30 degrees), 8×8

right45

RIGHTSHINGLE

right shingle pattern, 24×24

rightshingle

SMALLFISHSCALES

small fish scales pattern, 8×8

smallfishscales

VERTICAL

vertical line pattern, 8×8

vertical

VERTICAL2

vertical line pattern, 8×8

vertical2

VERTICAL3

vertical line pattern, 9×9

vertical3

VERTICALBRICKS

vertical brick pattern, 16×16

verticalbricks

VERTICALLEFTSHINGLE

vertical left shingle pattern, 24×24

verticalleftshingle

VERTICALRIGHTSHINGLE

vertical right shingle pattern, 24×24

verticalrightshingle

VERTICALSAW

vertical saw-tooth pattern, 8×16

verticalsaw