code: public static function getTransformation($orientation)
      {
          $transformation = '';
          if (
              (isset($GLOBALS['TYPO3_CONF_VARS']['GFX']['processor']) && $GLOBALS['TYPO3_CONF_VARS']['GFX']['processor'] === 'ImageMagick')
              ||
              (isset($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5']) && $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_version_5'] !== 'gm')
          ) {
              // ImageMagick
              if ($orientation >= 2 && $orientation <= 8) {
                  $transformation = '-auto-orient';
              }
          } else {
              // GraphicsMagick
              switch ($orientation) {
                  case 2: // horizontal flip
                      $transformation = '-flip horizontal';
                      break;
                  case 3: // 180°
                      $transformation = '-rotate 180';
                      break;
                  case 4: // vertical flip
                      $transformation = '-flip vertical';
                      break;
                  case 5: // vertical flip + 90 rotate right
                      $transformation = '-transpose';
                      break;
                  case 6: // 90° rotate right
                      $transformation = '-rotate 90';
                      break;
                  case 7: // horizontal flip + 90 rotate right
                      $transformation = '-transverse';
                      break;
                  case 8: // 90° rotate left
                      $transformation = '-rotate 270';
                      break;
              }
          }
          return $transformation;
      }
docs: Returns a command line parameter to fix the orientation of a rotated picture.
  
  @param integer $orientation
  @return string