You are here

protected function ImagemagickToolkit::parseFileViaGetImageSize in ImageMagick 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/ImageToolkit/ImagemagickToolkit.php \Drupal\imagemagick\Plugin\ImageToolkit\ImagemagickToolkit::parseFileViaGetImageSize()

Parses the image file using the PHP getimagesize() function.

Return value

bool TRUE if the file could be found and is an image, FALSE otherwise.

1 call to ImagemagickToolkit::parseFileViaGetImageSize()
ImagemagickToolkit::parseFile in src/Plugin/ImageToolkit/ImagemagickToolkit.php
Determines if a file contains a valid image.

File

src/Plugin/ImageToolkit/ImagemagickToolkit.php, line 1036

Class

ImagemagickToolkit
Provides ImageMagick integration toolkit for image manipulation.

Namespace

Drupal\imagemagick\Plugin\ImageToolkit

Code

protected function parseFileViaGetImageSize() {
  if ($data = @getimagesize($this
    ->getSourceLocalPath())) {
    $format = $this->formatMapper
      ->getFormatFromExtension(image_type_to_extension($data[2], FALSE));
    if ($format) {
      $this
        ->setSourceFormat($format)
        ->setWidth($data[0])
        ->setHeight($data[1]);
      return TRUE;
    }
  }
  return FALSE;
}