code: def filter_page_image(
      page: PageContext, image_filename: Path
  ) -> Path:
      """Called to filter the whole page before it is inserted into the PDF.
  
      A whole page image is only produced when preprocessing command line arguments
      are issued or when ``--force-ocr`` is issued. If no whole page is image is
      produced for a given page, this function will not be called. This is not
      the image that will be shown to OCR.
  
      If the function does not want to modify the image, it should return
      ``image_filename``. The hook may overwrite ``image_filename`` with a new file.
  
      The output image should preserve the same physical unit dimensions, that is
      ``(width * dpi_x, height * dpi_y)``. That is, if the image is resized, the DPI
      must be adjusted by the reciprocal. If this is not preserved, the PDF page
      will be resized and the OCR layer misaligned. OCRmyPDF does nothing
      to enforce these constraints; it is up to the plugin to do sensible things.
  
      OCRmyPDF will create the PDF page based on the image format used (unless the
      hook is overridden). If you convert the image to a JPEG, the output page will
      be created as a JPEG, etc. If you change the colorspace, that change will be
      kept. Note that the OCRmyPDF image optimization stage, if enabled, may
      ultimately chose a different format.
  
      If the return value is a file that does not exist, ``FileNotFoundError``
      will occur. The return value should be a path to a file in the same folder
      as ``image_filename``.
  
      Note:
          This hook will be called from child processes. Modifying global state
          will not affect the main process or other child processes.
  
      Note:
          This is a :ref:`firstresult hook<firstresult>`.
      """
  
imports: from __future__ import annotations
  from abc import ABC, abstractmethod
  from argparse import ArgumentParser, Namespace
  from collections.abc import Sequence, Set
  from logging import Handler
  from pathlib import Path
  from typing import TYPE_CHECKING, NamedTuple
  import pluggy
  from ocrmypdf import Executor, PdfContext
  from ocrmypdf._progressbar import ProgressBar
  from ocrmypdf.helpers import Resolution
label_desc: Use image node_id 10 for calling a global function with example usage: filter_page_image(page, image_filename) without return types