public function ImagickToolkit::parseFile in Imagick 8
Determines if a file contains a valid image.
Drupal supports GIF, JPG and PNG file formats when used with the GD toolkit, and may support others, depending on which toolkits are installed.
Return value
bool TRUE if the file could be found and is an image, FALSE otherwise.
Overrides ImageToolkitInterface::parseFile
File
- src/
Plugin/ ImageToolkit/ ImagickToolkit.php, line 248
Class
- ImagickToolkit
- Defines the Imagick toolkit for image manipulation within Drupal.
Namespace
Drupal\imagick\Plugin\ImageToolkitCode
public function parseFile() {
$success = FALSE;
try {
$resource = new Imagick();
$resource
->setBackgroundColor(new ImagickPixel('transparent'));
$resource
->readImage($this
->getPath());
$this
->setResource($resource);
$success = TRUE;
} catch (ImagickException $e) {
}
// cleanup local file if the original was remote
if ($this
->isRemoteUri($this
->getPath())) {
$this->fileSystem
->delete($this
->getPath());
}
return $success;
}