You are here

public function GDToolkit::getWidth in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php \Drupal\system\Plugin\ImageToolkit\GDToolkit::getWidth()

Returns the width of the image.

Return value

int|null The width of the image, or NULL if the image is invalid.

Overrides ImageToolkitInterface::getWidth

File

core/modules/system/src/Plugin/ImageToolkit/GDToolkit.php, line 323

Class

GDToolkit
Defines the GD2 toolkit for image manipulation within Drupal.

Namespace

Drupal\system\Plugin\ImageToolkit

Code

public function getWidth() {
  if ($this->preLoadInfo) {
    return $this->preLoadInfo[0];
  }
  elseif ($res = $this
    ->getResource()) {
    return imagesx($res);
  }
  else {
    return NULL;
  }
}