code: def create_thumbnail(
      infile, width=275, height=275, cx=0.5, cy=0.5, border=4
  ):
      """Overwrites `infile` with a new file of the given size"""
      im = image.imread(infile)
      rows, cols = im.shape[:2]
      size = min(rows, cols)
      if size == cols:
          xslice = slice(0, size)
          ymin = min(max(0, int(cx * rows - size // 2)), rows - size)
          yslice = slice(ymin, ymin + size)
      else:
          yslice = slice(0, size)
          xmin = min(max(0, int(cx * cols - size // 2)), cols - size)
          xslice = slice(xmin, xmin + size)
      thumb = im[yslice, xslice]
      thumb[:border, :, :3] = thumb[-border:, :, :3] = 0
      thumb[:, :border, :3] = thumb[:, -border:, :3] = 0
  
      dpi = 100
      fig = plt.figure(figsize=(width / dpi, height / dpi), dpi=dpi)
  
      ax = fig.add_axes(
          [0, 0, 1, 1],
          aspect="auto",
          frameon=False,
          xticks=[],
          yticks=[],
      )
      ax.imshow(
          thumb, aspect="auto", resample=True, interpolation="bilinear"
      )
      fig.savefig(infile, dpi=dpi)
      plt.close(fig)
      return fig
  
file_path: pymc-examples/sphinxext/thumbnail_extractor.py
imports: import base64
  import json
  import os
  import shutil
  from glob import glob
  import matplotlib
  import matplotlib.pyplot
  from matplotlib import image
  import sphinx
label_desc: Use image node_id 1 for calling a global function with example usage: create_thumbnail(infile, width, height, cx, cy, border) and returns: fig