Returns information whether the given file type is an image

@param string $mimeType The mime type of file
@return bool
966254
public static function isImage($mimeType)
    {
        if (in_array($mimeType, self::$mimeTypes, true)) {
            return (bool)preg_match('|^image/.+$|', $mimeType);
        }

        return false;
    }
655967
private static function isFileValid($filename, $mimeType, $allowedExts, $allowedMimeTypes) {
    // Skip if the allowed extensions or mime types are missing.
    if (!$allowedExts || !$allowedMimeTypes) {
      return false;
    }

    // Get extension.
    $extension = end($filename);

    return in_array(strtolower($mimeType), $allowedMimeTypes) && in_array(strtolower($extension), $allowedExts, true);
  }
908480
private function validateImageMimeType()
    {
        $imageType = exif_imagetype($this->uploadFile->getTemporaryFilename());
        $mime = image_type_to_mime_type($imageType);
        if (!$imageType || !in_array($mime, parent::getAllowedMimeTypes())) {
            throw new \Exception("Uploaded image appears to be corrupt"); // @codeCoverageIgnore
        }
    }
1334656
public function checkMimeType($fileInfo)
    {
        $mime = $fileInfo->getMimetype();
        if ($mime != 'directory' && !in_array($mime, $this->getFileManager()->getExtensionsAllowed())) {
            return 'Mime type "' . $mime . '" not allowed for file "' . $fileInfo->getFilename() . '"';
        }

        return true;
    }
475794
public static boolean hasMimeType(String mimeType) {
        if (mimeType == null || mimeType.isEmpty()) {
            return false;
        }
        return mimeTypeToExtensionMap.containsKey(mimeType);
    }
888610
public function isImage($filepath)
	{
		$this->debug->groupCollapsed(__METHOD__, $filepath);
		$isImage = false;
		if (false && function_exists('exif_imagetype')) {
			$type = exif_imagetype($filepath);
			$isImage = ($type !== false && in_array($type, $this->imagetypes));
		} else {
			$imageInfo = getimagesize($filepath);
			$mime = $imageInfo['mime'];
			// $this->debug->log('imageInfo', $imageInfo);
			$isImage = (isset($this->imageTypes[$mime]) && $imageInfo[0] && $imageInfo[1]);
		}
		$this->debug->groupEnd();
		return $isImage;
	}
459896
static public function guessByMimeType($mimeType)
    {
        switch (substr($mimeType, 0, strpos($mimeType, '/'))) {
            case 'audio' : return self::AUDIO; break;
            case 'image' : return self::IMAGE; break;
            case 'video' : return self::VIDEO; break;
        }

        if (preg_match('~zip|rar|compress~', $mimeType)) {
            return self::ARCHIVE;
        }

        if ($mimeType === 'application/x-shockwave-flash') {
            return self::FLASH;
        }

        return self::FILE;
    }
983291
public static function is_defaulticon_allowed($mimetype, $oldextension = '') {
        $mimeinfo = get_mimetypes_array();
        if ($oldextension !== '') {
            unset($mimeinfo[$oldextension]);
        }
        foreach ($mimeinfo as $extension => $values) {
            if ($values['type'] !== $mimetype) {
                continue;
            }
            if (!empty($values['defaulticon'])) {
                return false;
            }
        }
        return true;
    }
153805
public function matchMimetypeExtension($mimetype, $extension)
    {
        $mime_extensions = self::$mimetypes_extensions;
        if (isset($mime_extensions[$extension]) && $mime_extensions[$extension] == $mimetype) {
            return true;
        }

        return false;
    }
193093
public static function isGifFile($filename)
    {
        try {
            $image = new ImageFile($filename);
            if (strtolower($image->getMime()) !== @image_type_to_mime_type(IMAGETYPE_GIF)) {
                return false;
            }

            return true;
        } catch (\RuntimeException $ex) {
            return false;
        }
    }
936409
protected function validateMimeType () : bool
	{
		if (!is_array($this->allowedMimeTypes) || empty($this->allowedMimeTypes))
			return TRUE;
		if (!in_array($this->mimeType, $this->allowedMimeTypes)):
			$this->error = "Unsupported file type.";
			return FALSE;
		endif;
		return TRUE;
	}
1243244
public static function getMimeType($file) {
    $defaultType = 'application/octet-stream';
    if (class_exists('\FileInfo')) {
      // use extension
      $fileInfo = new finfo(FILEINFO_MIME);
      $fileType = $fileInfo->file(file_get_contents($file));
    }
    else {
      // try detect image mime type
      $imageInfo = @getimagesize($file);
      $fileType = isset($imageInfo['mime']) ? $imageInfo['mime'] : '';
    }
    return (is_string($fileType) && !empty($fileType)) ? $fileType : $defaultType;
  }
720726
public static function get_mime_extensions($mimetype = null)
    {
        static $mime_types, $mime_extensions;

        // return cached data
        if (is_array($mime_types)) {
            return $mimetype ? $mime_types[$mimetype] : $mime_extensions;
        }

        // load mapping file
        $file_paths = array();

        if ($mime_types = rcube::get_instance()->config->get('mime_types')) {
            $file_paths[] = $mime_types;
        }

        // try common locations
        if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
            $file_paths[] = 'C:/xampp/apache/conf/mime.types.';
        }
        else {
            $file_paths[] = '/etc/mime.types';
            $file_paths[] = '/etc/httpd/mime.types';
            $file_paths[] = '/etc/httpd2/mime.types';
            $file_paths[] = '/etc/apache/mime.types';
            $file_paths[] = '/etc/apache2/mime.types';
            $file_paths[] = '/etc/nginx/mime.types';
            $file_paths[] = '/usr/local/etc/httpd/conf/mime.types';
            $file_paths[] = '/usr/local/etc/apache/conf/mime.types';
            $file_paths[] = '/usr/local/etc/apache24/mime.types';
        }

        foreach ($file_paths as $fp) {
            if (@is_readable($fp)) {
                $lines = file($fp, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
                break;
            }
        }

        $mime_types = $mime_extensions = array();
        $regex = "/([\w\+\-\.\/]+)\s+([\w\s]+)/i";
        foreach ((array)$lines as $line) {
             // skip comments or mime types w/o any extensions
            if ($line[0] == '#' || !preg_match($regex, $line, $matches))
                continue;

            $mime = $matches[1];
            foreach (explode(' ', $matches[2]) as $ext) {
                $ext = trim($ext);
                $mime_types[$mime][] = $ext;
                $mime_extensions[$ext] = $mime;
            }
        }

        // fallback to some well-known types most important for daily emails
        if (empty($mime_types)) {
            foreach (rcube::get_instance()->config->resolve_paths('mimetypes.php') as $fpath) {
                $mime_extensions = array_merge($mime_extensions, (array) @include($fpath));
            }

            foreach ($mime_extensions as $ext => $mime) {
                $mime_types[$mime][] = $ext;
            }
        }

        // Add some known aliases that aren't included by some mime.types (#1488891)
        // the order is important here so standard extensions have higher prio
        $aliases = array(
            'image/gif'      => array('gif'),
            'image/png'      => array('png'),
            'image/x-png'    => array('png'),
            'image/jpeg'     => array('jpg', 'jpeg', 'jpe'),
            'image/jpg'      => array('jpg', 'jpeg', 'jpe'),
            'image/pjpeg'    => array('jpg', 'jpeg', 'jpe'),
            'image/tiff'     => array('tif'),
            'message/rfc822' => array('eml'),
            'text/x-mail'    => array('eml'),
        );

        foreach ($aliases as $mime => $exts) {
            $mime_types[$mime] = array_unique(array_merge((array) $mime_types[$mime], $exts));

            foreach ($exts as $ext) {
                if (!isset($mime_extensions[$ext])) {
                    $mime_extensions[$ext] = $mime;
                }
            }
        }

        return $mimetype ? $mime_types[$mimetype] : $mime_extensions;
    }
12865
public function type($mimetype) {
		// if the type is correct
		if(in_array($mimetype, $this->Allowed)) {
			// set the type
			$this->Output = $mimetype;
		}
		// return self
		return($this);
	}
1188906
private function isImage()
    {
        if ($this->metadata->isFile() &&
            mb_strpos($this->metadata->getMimeType(), 'image/') === 0
        ) {
            return true;
        }

        return false;
    }
582965
public function getMimeType()
    {
        if (empty($this->mimeType)) {
            $resource = finfo_open(FILEINFO_MIME_TYPE);
            $this->mimeType = finfo_file($resource, $this->getRealPath());
        }

        return $this->mimeType;
    }
440223
public function fileExtensions($mimeType)
    {

        $mimeType = mb_strtolower($mimeType);

        $this->loadBaseSetIfNotLoaded();

        if (isset($this->extensionsByType[$mimeType])) {
            return $this->extensionsByType[$mimeType];
        }

        if ($this->extendedSetLoaded) {
            throw new ResourceNotFoundException("Mimetype '$mimeType' not found");
        }

        $this->loadExtendedSet();

        $this->extendedSetLoaded = true;

        return $this->fileExtensions($mimeType);

    }