Media Server 12.11

# LuaScript

The Lua script that returns the rotation to apply to the input image, in degrees, clockwise.

Specify one of the following:

- the absolute path to the Lua script file.
- the path to the Lua script file, relative to the LuaDirectory.
- a string that matches one of your `AdditionalDataLabels`, (if you use the `AdditionalData` and `AdditionalDataLabels` action parameters to upload the Lua script file as part of the Process action).

TIP: If your script is relatively short, for example a single line, you can set the parameter `LuaLine` instead of `LuaScript`. The `LuaLine` parameter allows you to specify a small amount of Lua code directly in the configuration file, removing the need for a separate script file.

The Lua script must define a function named `getAngle`, which must return the angle. Media Server can rotate images in 90-degree increments, so all other angles are rounded.

The following is an example Lua script that you could use to rotate images based on the angle of a face detected in the image, or text detected in the image. In this example, the angles returned are negative, so the rotation is anticlockwise.

    function getAngle(record)
      if (record.OCRResultAndImage) then
         return -record.OCRResultAndImage.angle
      elseif (record.FaceResultAndImage) then
         return -record.FaceResultAndImage.face.ellipse.angle
      elseif (record.FaceRecognitionResultAndImage) then
         return -record.FaceRecognitionResultAndImage.face.ellipse.angle
      elseif (record.DemographicsResultAndImage) then
         return -record.DemographicsResultAndImage.face.ellipse.angle
      elseif (record.FaceStateResultAndImage) then
         return -record.FaceStateResultAndImage.face.ellipse.angle
      end

      return 0
    end

If you set neither this parameter nor Angle, Media Server attempts to make the image upright by looking for an angle in the input data (records from tasks such as face detection and OCR contain angles).

Type: | String
Default: |
Required: | No
Configuration Section: | TaskName
Example: | `LuaScript=rotate.lua`
See Also: | Angle

© Copyright 2022 Micro Focus or one of its affiliates
Version 12.11 | Last updated February 2022

Send documentation feedback

Close

Send documentation feedback

To send feedback using your default email client, open an email window.

Otherwise, send your feedback and the information below to swpdl.idoldocsfeedback@microfocus.com.

We appreciate your feedback!

Product: IDOL Media Server 12.11

Topic Title: LuaScript