code: def filter_page_image(page, image_filename):
      if page.options.mono_page:
          with Image.open(image_filename) as im:
              im = im.convert("1")
              im.save(image_filename)
          return image_filename
      else:
          output = image_filename.with_suffix(".jpg")
          with Image.open(image_filename) as im:
              im.save(output)
          return output
  
file_path: OCRmyPDF/misc/example_plugin.py
imports: from __future__ import annotations
  import logging
  from PIL import Image
  from ocrmypdf import hookimpl
label_desc: Use image node_id 5 for calling a global function with example usage: filter_page_image(page, image_filename) and returns: image_filename, output