code: def guess_mimetype(
      filename: PathLike[str] | str = "",
      default: str | None = None,
  ) -> str | None:
      ext = path.splitext(filename)[1].lower()
      if ext in mime_suffixes:
          return mime_suffixes[ext]
      if path.exists(filename):
          try:
              imgtype = _image_type_from_file(filename)
          except ValueError:
              pass
          else:
              return "image/" + imgtype
      return default
  
file_path: sphinx/sphinx/util/images.py
imports: from __future__ import annotations
  import base64
  from os import path
  from typing import TYPE_CHECKING, NamedTuple, overload
  import imagesize
label_desc: Use image node_id 4 for calling a global function with example usage: guess_mimetype(filename, default) and returns: default, mime_suffixes, unknown