You are here

public function ImagemagickToolkit::save in ImageMagick 8.2

Same name and namespace in other branches
  1. 8.3 src/Plugin/ImageToolkit/ImagemagickToolkit.php \Drupal\imagemagick\Plugin\ImageToolkit\ImagemagickToolkit::save()
  2. 8 src/Plugin/ImageToolkit/ImagemagickToolkit.php \Drupal\imagemagick\Plugin\ImageToolkit\ImagemagickToolkit::save()

Writes an image resource to a destination file.

Parameters

string $destination: A string file URI or path where the image should be saved.

Return value

bool TRUE on success, FALSE on failure.

Overrides ImageToolkitInterface::save

File

src/Plugin/ImageToolkit/ImagemagickToolkit.php, line 1204

Class

ImagemagickToolkit
Provides ImageMagick integration toolkit for image manipulation.

Namespace

Drupal\imagemagick\Plugin\ImageToolkit

Code

public function save($destination) {
  $this
    ->arguments()
    ->setDestination($destination);
  if ($ret = $this
    ->convert()) {

    // Allow modules to alter the destination file.
    $this->moduleHandler
      ->alterDeprecated('Deprecated in 8.x-2.5, will be removed in 8.x-3.0. Use an event subscriber to react on a ImagemagickExecutionEvent::POST_SAVE event. See https://www.drupal.org/project/imagemagick/issues/3043136.', 'imagemagick_post_save', $this->arguments);
    $this->eventDispatcher
      ->dispatch(ImagemagickExecutionEvent::POST_SAVE, new ImagemagickExecutionEvent($this->arguments));

    // Reset local path to allow saving to other file.
    $this
      ->arguments()
      ->setDestinationLocalPath('');
  }
  return $ret;
}