# Rotate Images

To configure Media Server to rotate images, follow these steps.

To rotate images

1. Create a new configuration to send to Media Server with the `process` action, or open an existing configuration that you want to modify.

2. In the `[Session]` section, add a new task by setting the `EngineN` parameter. You can give the task any name, for example:

       [Session]
       Engine0=Ingest
       ...
       Engine3=Rotation

3. Create a new configuration section to contain the task settings and set the following parameters:

   `Type` | The transformation engine to use. Set this parameter to `Rotate`.
   `Input` | The name of the image track to process.
   `Angle` | (Set this or `LuaScript`) The rotation to apply to the input image, in degrees, clockwise.
   `LuaScript` | (Set this or `Angle`) The path to a Lua script that returns the rotation to apply to the input image, in degrees, clockwise. 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.

   For example:

       [Rotation]
       Type=Rotate
       Input=FaceDetect.ResultWithSource
       LuaScript=Rotate.Lua

   A suitable Lua script is included below:

       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

4. Save and close the configuration file. Micro Focus recommends that you save your configuration files in the location specified by the `ConfigDirectory` parameter.

© Copyright 2019 Micro Focus or one of its affiliates | Send documentation feedback Close Send documentation feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a mail client, and then send this email to swpdl.idoldocsfeedback@microfocus.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_FT_HTML5_bannerTitle.htm