You are here

protected function AutoOrient::execute in Image Effects 8.3

Same name in this branch
  1. 8.3 src/Plugin/ImageToolkit/Operation/gd/AutoOrient.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\gd\AutoOrient::execute()
  2. 8.3 src/Plugin/ImageToolkit/Operation/imagemagick/AutoOrient.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\imagemagick\AutoOrient::execute()
Same name and namespace in other branches
  1. 8 src/Plugin/ImageToolkit/Operation/imagemagick/AutoOrient.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\imagemagick\AutoOrient::execute()
  2. 8.2 src/Plugin/ImageToolkit/Operation/imagemagick/AutoOrient.php \Drupal\image_effects\Plugin\ImageToolkit\Operation\imagemagick\AutoOrient::execute()

File

src/Plugin/ImageToolkit/Operation/imagemagick/AutoOrient.php, line 31

Class

AutoOrient
Defines ImageMagick AutoOrient operation.

Namespace

Drupal\image_effects\Plugin\ImageToolkit\Operation\imagemagick

Code

protected function execute(array $arguments) {
  $this
    ->addArgument('-auto-orient');

  // Swap toolkit's height and width when picture orientation is vertical.
  if (in_array($this
    ->getToolkit()
    ->getExifOrientation(), [
    5,
    6,
    7,
    8,
  ])) {
    $tmp = $this
      ->getToolkit()
      ->getWidth();
    $this
      ->getToolkit()
      ->setWidth($this
      ->getToolkit()
      ->getHeight());
    $this
      ->getToolkit()
      ->setHeight($tmp);
    $this
      ->getToolkit()
      ->setExifOrientation(NULL);
  }
  return TRUE;
}