You are here

public function ImagemagickFormatMapper::getFormatFromExtension in ImageMagick 8.3

Same name and namespace in other branches
  1. 8 src/ImagemagickFormatMapper.php \Drupal\imagemagick\ImagemagickFormatMapper::getFormatFromExtension()
  2. 8.2 src/ImagemagickFormatMapper.php \Drupal\imagemagick\ImagemagickFormatMapper::getFormatFromExtension()

Gets the image format, given the image file extension.

Parameters

string $extension: An image file extension (e.g. jpeg, jpg, png, etc.), without leading dot.

Return value

string|null The ImageMagick internal format (e.g. JPEG, GIF87, etc.) of the specified extension, if the format is enabled in the toolkit. NULL otherwise.

Overrides ImagemagickFormatMapperInterface::getFormatFromExtension

File

src/ImagemagickFormatMapper.php, line 144

Class

ImagemagickFormatMapper
Provides the ImageMagick format mapper.

Namespace

Drupal\imagemagick

Code

public function getFormatFromExtension(string $extension) {
  $extension = mb_strtolower($extension);
  $enabled_extensions = $this
    ->resolveEnabledExtensions();
  return $extension ? isset($enabled_extensions[$extension]) ? $enabled_extensions[$extension] : NULL : NULL;
}