code: def jpeg_factory(fp=None, filename=None):
      im = JpegImageFile(fp, filename)
      try:
          mpheader = im._getmp()
          if mpheader[45057] > 1:
              # It's actually an MPO
              from .MpoImagePlugin import MpoImageFile
  
              # Don't reload everything, just convert it.
              im = MpoImageFile.adopt(im, mpheader)
      except (TypeError, IndexError):
          # It is really a JPEG
          pass
      except SyntaxError:
          warnings.warn(
              "Image appears to be a malformed MPO file, it will be "
              "interpreted as a base JPEG file"
          )
      return im
  
imports: import array
  import io
  import math
  import os
  import struct
  import subprocess
  import sys
  import tempfile
  import warnings
  from .None import Image, ImageFile
  from ._binary import i16be
  from ._binary import i32be
  from ._binary import o8
  from ._binary import o16be
  from .JpegPresets import presets
label_desc: Use image node_id 12 for calling a global function with example usage: jpeg_factory(fp, filename) and returns: im