You are here

protected function Convert::execute in ImageMagick 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/ImageToolkit/Operation/imagemagick/Convert.php \Drupal\imagemagick\Plugin\ImageToolkit\Operation\imagemagick\Convert::execute()
  2. 8.2 src/Plugin/ImageToolkit/Operation/imagemagick/Convert.php \Drupal\imagemagick\Plugin\ImageToolkit\Operation\imagemagick\Convert::execute()

Performs the actual manipulation on the image.

Image toolkit operation implementers must implement this method. This method is responsible for actually performing the operation on the image. When this method gets called, the implementer may assume all arguments, also the optional ones, to be available, validated and corrected.

Parameters

array $arguments: An associative array of arguments to be used by the toolkit operation.

Return value

bool TRUE if the operation was performed successfully, FALSE otherwise.

Overrides ImageToolkitOperationBase::execute

File

src/Plugin/ImageToolkit/Operation/imagemagick/Convert.php, line 42

Class

Convert
Defines imagemagick Convert operation.

Namespace

Drupal\imagemagick\Plugin\ImageToolkit\Operation\imagemagick

Code

protected function execute(array $arguments) {

  // When source image is multi-frame, convert only the first frame.
  if ($this
    ->getToolkit()
    ->getFrames()) {
    $path = $this
      ->getToolkit()
      ->getSourceLocalPath();
    if (strripos($path, '[0]', -3) === FALSE) {
      $this
        ->getToolkit()
        ->setSourceLocalPath($path . '[0]');
    }
  }
  $this
    ->getToolkit()
    ->setFrames(NULL)
    ->setDestinationFormatFromExtension($arguments['extension']);
  return TRUE;
}