You are here

public function AutoOrientImageEffect::applyEffect in Image Effects 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/ImageEffect/AutoOrientImageEffect.php \Drupal\image_effects\Plugin\ImageEffect\AutoOrientImageEffect::applyEffect()
  2. 8.2 src/Plugin/ImageEffect/AutoOrientImageEffect.php \Drupal\image_effects\Plugin\ImageEffect\AutoOrientImageEffect::applyEffect()

Applies an image effect to the image object.

Parameters

\Drupal\Core\Image\ImageInterface $image: An image file object.

Return value

bool TRUE on success. FALSE if unable to perform the image effect on the image.

Overrides ImageEffectInterface::applyEffect

File

src/Plugin/ImageEffect/AutoOrientImageEffect.php, line 151

Class

AutoOrientImageEffect
Automatically adjusts the orientation of an image resource.

Namespace

Drupal\image_effects\Plugin\ImageEffect

Code

public function applyEffect(ImageInterface $image) {

  // Test to see if EXIF is supported by the image format.
  if (in_array($image
    ->getMimeType(), [
    'image/jpeg',
    'image/tiff',
  ])) {

    // Hand over to toolkit.
    return $image
      ->apply('auto_orient');
  }
  return TRUE;
}