code: def triage_image_file(
      input_file: Path, output_file: Path, options
  ) -> None:
      """Triage the input image file.
  
      If the input file is an image, check its resolution and convert it to PDF.
  
      Args:
          input_file: The path to the input file.
          output_file: The path to the output file.
          options: An object containing the options passed to the OCRmyPDF command.
  
      Raises:
          UnsupportedImageFormatError: If the input file is not a supported image format.
          DpiError: If the input image has no resolution (DPI) in its metadata or if the
              resolution is not credible.
      """
      log.info("Input file is not a PDF, checking if it is an image...")
      try:
          im = Image.open(input_file)
      except OSError as e:
          # Recover the original filename
          log.error(
              str(e).replace(str(input_file), str(options.input_file))
          )
          raise UnsupportedImageFormatError() from e
  
      with im:
          log.info("Input file is an image")
          if "dpi" in im.info:
              if im.info["dpi"] <= (96, 96) and not options.image_dpi:
                  log.info("Image size: (%d, %d)", *im.size)
                  log.info(
                      "Image resolution: (%d, %d)", *im.info["dpi"]
                  )
                  raise DpiError(
                      "Input file is an image, but the resolution (DPI) is "
                      "not credible.  Estimate the resolution at which the "
                      "image was scanned and specify it using --image-dpi."
                  )
          elif not options.image_dpi:
              log.info("Image size: (%d, %d)", *im.size)
              raise DpiError(
                  "Input file is an image, but has no resolution (DPI) "
                  "in its metadata.  Estimate the resolution at which "
                  "image was scanned and specify it using --image-dpi."
              )
  
          if im.mode in ("RGBA", "LA"):
              raise UnsupportedImageFormatError(
                  "The input image has an alpha channel. Remove the alpha "
                  "channel first."
              )
  
          if "iccprofile" not in im.info:
              if im.mode == "RGB":
                  log.info(
                      "Input image has no ICC profile, assuming sRGB"
                  )
              elif im.mode == "CMYK":
                  raise UnsupportedImageFormatError(
                      "Input CMYK image has no ICC profile, not usable"
                  )
  
      try:
          log.info("Image seems valid. Try converting to PDF...")
          layout_fun = img2pdf.default_layout_fun
          if options.image_dpi:
              layout_fun = img2pdf.get_fixed_dpi_layout_fun(
                  Resolution(options.image_dpi, options.image_dpi)
              )
          with open(output_file, "wb") as outf:
              img2pdf.convert(
                  os.fspath(input_file),
                  layout_fun=layout_fun,
                  outputstream=outf,
                  **IMG2PDF_KWARGS,
              )
          log.info("Successfully converted to PDF, processing...")
      except img2pdf.ImageOpenError as e:
          raise UnsupportedImageFormatError() from e
  
imports: from __future__ import annotations
  import logging
  import os
  import re
  import sys
  from collections.abc import Iterable, Iterator, Sequence
  from contextlib import suppress
  from pathlib import Path
  from shutil import copyfileobj, copystat
  from typing import Any, BinaryIO, TypeVar, cast
  import img2pdf
  import pikepdf
  from PIL import Image, ImageColor, ImageDraw
  from ocrmypdf._concurrent import Executor
  from ocrmypdf._exec import unpaper
  from ocrmypdf._jobcontext import PageContext, PdfContext
  from ocrmypdf._metadata import repair_docinfo_nuls
  from ocrmypdf.exceptions import DigitalSignatureError, DpiError, EncryptedPdfError, InputFileError, PriorOcrFoundError, TaggedPDFError, UnsupportedImageFormatError
  from ocrmypdf.helpers import IMG2PDF_KWARGS, Resolution, safe_symlink
  from ocrmypdf.hocrtransform import DebugRenderOptions, HocrTransform
  from ocrmypdf.hocrtransform._font import Courier
  from ocrmypdf.pdfa import generate_pdfa_ps
  from ocrmypdf.pdfinfo import Colorspace, Encoding, PageInfo, PdfInfo
  from ocrmypdf.pluginspec import OrientationConfidence
label_desc: Use image node_id 1 for calling a global function with example usage: triage_image_file(input_file, output_file, options) without return types