code: def create_thumbnail(
      infile, thumbfile, width=300, height=300, cx=0.5, cy=0.6, border=4
  ):
      # this doesn't really matter, it will cancel in the end, but we
      # need it for the mpl API
      dpi = 100
  
      baseout, extout = os.path.splitext(thumbfile)
      im = image.imread(infile)
      rows, cols = im.shape[:2]
      x0 = int(cx * cols - 0.5 * width)
      y0 = int(cy * rows - 0.5 * height)
      thumb = im[y0 : y0 + height, x0 : x0 + width]
      thumb[:border, :, :3] = thumb[-border:, :, :3] = 0
      thumb[:, :border, :3] = thumb[:, -border:, :3] = 0
  
      extension = extout.lower()
  
      if extension == ".png":
          from matplotlib.backends.backend_agg import (
              FigureCanvasAgg as FigureCanvas,
          )
      elif extension == ".pdf":
          from matplotlib.backends.backend_pdf import (
              FigureCanvasPDF as FigureCanvas,
          )
      elif extension == ".svg":
          from matplotlib.backends.backend_svg import (
              FigureCanvasSVG as FigureCanvas,
          )
      else:
          raise ValueError(
              "Can only handle extensions 'png', 'svg' or 'pdf'"
          )
  
      fig = Figure(
          figsize=(float(width) / dpi, float(height) / dpi), dpi=dpi
      )
      canvas = FigureCanvas(fig)
  
      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(thumbfile, dpi=dpi)
      return fig
  
imports: import sys
  import os
  import glob
  import token
  import tokenize
  import shutil
  import json
  import matplotlib
  import mpld3
  from matplotlib import image
  from matplotlib.figure import Figure
label_desc: Use image node_id 1 for calling a global function with example usage: create_thumbnail(infile, thumbfile, width, height, cx, cy, border) and returns: fig