class_docstr: Image files collector for sphinx.environment.
docstr: Process and rewrite image URIs.
docstr_tok: ["Process","and","rewrite","image","URIs","."]
code: def process_doc(self, app: Sphinx, doctree: nodes.document) -> None:
      """Process and rewrite image URIs."""
      docname = app.env.docname
  
      for node in doctree.findall(nodes.image):
          # Map the mimetype to the corresponding image.  The writer may
          # choose the best image from these candidates.  The special key * is
          # set if there is only single candidate to be used by a writer.
          # The special key ? is set for nonlocal URIs.
          candidates: dict[str, str] = {}
          node["candidates"] = candidates
          imguri = node["uri"]
          if imguri.startswith("data:"):
              candidates["?"] = imguri
              continue
          if imguri.find("://") != -1:
              candidates["?"] = imguri
              continue
  
          if imguri.endswith(os.extsep + "*"):
              # Update `node['uri']` to a relative path from srcdir
              # from a relative path from current document.
              rel_imgpath, full_imgpath = app.env.relfn2path(
                  imguri, docname
              )
              node["uri"] = rel_imgpath
  
              # Search language-specific figures at first
              i18n_imguri = get_image_filename_for_language(
                  imguri, app.env
              )
              _, full_i18n_imgpath = app.env.relfn2path(
                  i18n_imguri, docname
              )
              self.collect_candidates(
                  app.env, full_i18n_imgpath, candidates, node
              )
  
              self.collect_candidates(
                  app.env, full_imgpath, candidates, node
              )
          else:
              # substitute imguri by figure_language_filename
              # (ex. foo.png -> foo.en.png)
              imguri = search_image_for_language(imguri, app.env)
  
              # Update `node['uri']` to a relative path from srcdir
              # from a relative path from current document.
              original_uri = node["uri"]
              node["uri"], _ = app.env.relfn2path(imguri, docname)
              candidates["*"] = node["uri"]
              if node["uri"] != original_uri:
                  node["original_uri"] = original_uri
  
          # map image paths to unique image names (so that they can be put
          # into a single directory)
          for imgpath in candidates.values():
              app.env.dependencies[docname].add(imgpath)
              if not os.access(path.join(app.srcdir, imgpath), os.R_OK):
                  logger.warning(
                      __("image file not readable: %s") % imgpath,
                      location=node,
                      type="image",
                      subtype="not_readable",
                  )
                  continue
              app.env.images.add_file(docname, imgpath)
  
imports: from __future__ import annotations
  import os
  from glob import glob
  from os import path
  from typing import TYPE_CHECKING, Any
  from docutils import nodes
  from docutils.utils import relative_path
  from sphinx import addnodes
  from sphinx.environment.collectors import EnvironmentCollector
  from sphinx.locale import __
  from sphinx.util import logging
  from sphinx.util.i18n import get_image_filename_for_language, search_image_for_language
  from sphinx.util.images import guess_mimetype
label_desc: Use image node_id 3 for calling the ImageCollector obj's underlying member method code with example usage: obj.process_doc(app, doctree) without return types