Convert.php in ImageMagick 8
File
src/Plugin/ImageToolkit/Operation/imagemagick/Convert.php
View source
<?php
namespace Drupal\imagemagick\Plugin\ImageToolkit\Operation\imagemagick;
class Convert extends ImagemagickImageToolkitOperationBase {
protected function arguments() {
return [
'extension' => [
'description' => 'The new extension of the converted image',
],
];
}
protected function validateArguments(array $arguments) {
if (!in_array($arguments['extension'], $this
->getToolkit()
->getSupportedExtensions())) {
throw new \InvalidArgumentException("Invalid extension ({$arguments['extension']}) specified for the image 'convert' operation");
}
return $arguments;
}
protected function execute(array $arguments) {
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;
}
}
Classes
Name |
Description |
Convert |
Defines imagemagick Convert operation. |