trait ImagickOperationTrait in Imagick 8
Class ImagickOperationTrait
Hierarchy
- trait \Drupal\imagick\Plugin\ImageToolkit\Operation\imagick\ImagickOperationTrait
File
- src/
Plugin/ ImageToolkit/ Operation/ imagick/ ImagickOperationTrait.php, line 10
Namespace
Drupal\imagick\Plugin\ImageToolkit\Operation\imagickView source
trait ImagickOperationTrait {
/**
* {@inheritdoc}
*/
protected function execute(array $arguments) {
return $this
->processFrames($arguments);
}
/**
* Process image frames for GIFs
*
* @param array $arguments
* @return bool
*/
protected function processFrames(array $arguments = []) {
/* @var $resource Imagick */
$resource = $this
->getToolkit()
->getResource();
// If preferred format is set, use it as prefix for writeImage
// If not this will throw a ImagickException exception
try {
$image_format = $resource
->getImageFormat();
} catch (ImagickException $e) {
}
$success = TRUE;
if (isset($image_format) && in_array($image_format, [
'GIF',
])) {
// Get each frame in the GIF
$resource = $resource
->coalesceImages();
do {
if (!$this
->process($resource, $arguments)) {
$success = FALSE;
break;
}
} while ($resource
->nextImage());
$resource
->deconstructImages();
}
else {
$success = $this
->process($resource, $arguments);
}
// Set the processed resource
$this
->getToolkit()
->setResource($resource);
return $success;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ImagickOperationTrait:: |
protected | function | 3 | |
ImagickOperationTrait:: |
protected | function | Process image frames for GIFs |