protected function GDToolkit::load in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php \Drupal\system\Plugin\ImageToolkit\GDToolkit::load()
Loads a GD resource from a file.
Return value
bool TRUE or FALSE, based on success.
1 call to GDToolkit::load()
- GDToolkit::getResource in core/
modules/ system/ src/ Plugin/ ImageToolkit/ GDToolkit.php - Retrieves the GD image resource.
File
- core/
modules/ system/ src/ Plugin/ ImageToolkit/ GDToolkit.php, line 178 - Contains \Drupal\system\Plugin\ImageToolkit\GDToolkit.
Class
- GDToolkit
- Defines the GD2 toolkit for image manipulation within Drupal.
Namespace
Drupal\system\Plugin\ImageToolkitCode
protected function load() {
// Return immediately if the image file is not valid.
if (!$this
->isValid()) {
return FALSE;
}
$function = 'imagecreatefrom' . image_type_to_extension($this
->getType(), FALSE);
if (function_exists($function) && ($resource = $function($this
->getSource()))) {
$this
->setResource($resource);
if (imageistruecolor($resource)) {
return TRUE;
}
else {
// Convert indexed images to truecolor, copying the image to a new
// truecolor resource, so that filters work correctly and don't result
// in unnecessary dither.
$data = array(
'width' => imagesx($resource),
'height' => imagesy($resource),
'extension' => image_type_to_extension($this
->getType(), FALSE),
'transparent_color' => $this
->getTransparentColor(),
'is_temp' => TRUE,
);
if ($this
->apply('create_new', $data)) {
imagecopy($this
->getResource(), $resource, 0, 0, 0, 0, imagesx($resource), imagesy($resource));
imagedestroy($resource);
}
}
return (bool) $this
->getResource();
}
return FALSE;
}