You are here

function hook_imagemagick_arguments_alter in ImageMagick 8.2

Same name and namespace in other branches
  1. 8 imagemagick.api.php \hook_imagemagick_arguments_alter()
  2. 7 imagemagick.api.php \hook_imagemagick_arguments_alter()

Alter the arguments to ImageMagick command-line executables.

This hook is executed just before Imagemagick executables are called. It allows to change file paths for source and destination image files, and/or to alter the command line arguments that are passed to the binaries. The toolkit provides methods to prepend, add, find, get and reset arguments that have already been set by image effects.

In addition to arguments that are passed to the binaries command line for execution, it is possible to push arguments to be used only by the toolkit or the hooks. You can add/get/find such arguments by specifying ImagemagickExecArguments::INTERNAL as the argument $mode in the methods.

ImageMagick automatically converts the target image to the format denoted by the file extension. However, since changing the file extension is not always an option, you can specify an alternative image format via $arguments->setDestinationFormat('format'), where 'format' is a string denoting an Imagemagick supported format, or via $arguments->setDestinationFormatFromExtension('extension'), where 'extension' is a string denoting an image file extension.

When the destination format is set, it is passed to ImageMagick's convert binary with the syntax "[format]:[destination]".

Parameters

\Drupal\imagemagick\ImagemagickExecArguments $arguments: The ImageMagick/GraphicsMagick execution arguments object.

string $command: The ImageMagick/GraphicsMagick command being called.

Deprecated

in 8.x-2.5, will be removed in 8.x-3.0. Use an event subscriber to react on a ImagemagickExecutionEvent::PRE_IDENTIFY_EXECUTE or a ImagemagickExecutionEvent::PRE_CONVERT_EXECUTE event.

See also

https://www.drupal.org/project/imagemagick/issues/3043136

http://www.imagemagick.org/script/command-line-processing.php#output

http://www.imagemagick.org/Usage/files/#save

\Drupal\imagemagick\ImagemagickExecArguments

\Drupal\imagemagick\Plugin\ImageToolkit\ImagemagickToolkit::convert()

\Drupal\imagemagick\Plugin\FileMetadata\ImagemagickIdentify::identify()

1 function implements hook_imagemagick_arguments_alter()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

imagemagick_test_imagemagick_arguments_alter in tests/modules/imagemagick_test/imagemagick_test.module
Implements hook_imagemagick_arguments_alter().

File

./imagemagick.api.php, line 99
API documentation for the ImageMagick module.

Code

function hook_imagemagick_arguments_alter(\Drupal\imagemagick\ImagemagickExecArguments $arguments, $command) {
}