code: def extract_image_filter(
      image: Stream, xref: Xref
  ) -> tuple[PdfImage, tuple[Name, Object]] | None:
      """Determine if an image is extractable."""
      if image.Subtype != Name.Image:
          return None
      if image.Length < 100:
          log.debug(
              f"xref {xref}: skipping image with small stream size"
          )
          return None
      if image.Width < 8 or image.Height < 8:  # Issue 732
          log.debug(
              f"xref {xref}: skipping image with unusually small dimensions"
          )
          return None
  
      pim = PdfImage(image)
  
      if len(pim.filter_decodeparms) > 1:
          first_filtdp = pim.filter_decodeparms[0]
          second_filtdp = pim.filter_decodeparms[1]
          if (
              len(pim.filter_decodeparms) == 2
              and first_filtdp[0] == Name.FlateDecode
              and first_filtdp[1].get(Name.Predictor, 1) == 1
              and second_filtdp[0] == Name.DCTDecode
              and not second_filtdp[1]
          ):
              log.debug(
                  f"xref {xref}: found image compressed as /FlateDecode /DCTDecode, "
                  "marked for JPEG optimization"
              )
              filtdp = pim.filter_decodeparms[1]
          else:
              log.debug(
                  f"xref {xref}: skipping image with multiple compression filters"
              )
              return None
      else:
          filtdp = pim.filter_decodeparms[0]
  
      if pim.bits_per_component > 8:
          log.debug(f"xref {xref}: skipping wide gamut image")
          return None  # Don't mess with wide gamut images
  
      if filtdp[0] == Name.JPXDecode:
          log.debug(f"xref {xref}: skipping JPEG2000 image")
          return None  # Don't do JPEG2000
  
      if (
          filtdp[0] == Name.CCITTFaxDecode
          and filtdp[1].get("/K", 0) >= 0
      ):
          log.debug(f"xref {xref}: skipping CCITT Group 3 image")
          return None  # pikepdf doesn't support Group 3 yet
  
      if Name.Decode in image:
          log.debug(f"xref {xref}: skipping image with Decode table")
          return None  # Don't mess with custom Decode tables
  
      return pim, filtdp
  
imports: from __future__ import annotations
  import logging
  import sys
  import tempfile
  import threading
  from collections import defaultdict
  from collections.abc import Iterator, MutableSet, Sequence
  from os import fspath
  from pathlib import Path
  from typing import Any, Callable, NamedTuple, NewType
  from warnings import warn
  from zlib import compress
  import img2pdf
  from pikepdf import Dictionary, Name, Object, ObjectStreamMode, Pdf, PdfError, PdfImage, Stream, UnsupportedImageTypeError
  from PIL import Image
  from ocrmypdf._concurrent import Executor, SerialExecutor
  from ocrmypdf._exec import jbig2enc, pngquant
  from ocrmypdf._jobcontext import PdfContext
  from ocrmypdf._progressbar import ProgressBar
  from ocrmypdf.exceptions import OutputFileAccessError
  from ocrmypdf.helpers import IMG2PDF_KWARGS, safe_symlink
label_desc: Use image node_id 4 for calling a global function with example usage: extract_image_filter(image, xref) and returns: pim,  filtdp, None, None, None, None, None, None, None, None