code: def SOF(self, marker):
      #
      # Start of frame marker.  Defines the size and mode of the
      # image.  JPEG is colour blind, so we use some simple
      # heuristics to map the number of layers to an appropriate
      # mode.  Note that this could be made a bit brighter, by
      # looking for JFIF and Adobe APP markers.
  
      n = i16(self.fp.read(2)) - 2
      s = ImageFile._safe_read(self.fp, n)
      self._size = i16(s, 3), i16(s, 1)
  
      self.bits = s[0]
      if self.bits != 8:
          raise SyntaxError(f"cannot handle {self.bits}-bit layers")
  
      self.layers = s[5]
      if self.layers == 1:
          self.mode = "L"
      elif self.layers == 3:
          self.mode = "RGB"
      elif self.layers == 4:
          self.mode = "CMYK"
      else:
          raise SyntaxError(f"cannot handle {self.layers}-layer images")
  
      if marker in [0xFFC2, 0xFFC6, 0xFFCA, 0xFFCE]:
          self.info["progressive"] = self.info["progression"] = 1
  
      if self.icclist:
          # fixup icc profile
          self.icclist.sort()  # sort by sequence number
          if self.icclist[0][13] == len(self.icclist):
              profile = []
              for p in self.icclist:
                  profile.append(p[14:])
              icc_profile = b"".join(profile)
          else:
              icc_profile = None  # wrong number of fragments
          self.info["icc_profile"] = icc_profile
          self.icclist = []
  
      for i in range(6, len(s), 3):
          t = s[i : i + 3]
          # 4-tuples: id, vsamp, hsamp, qtable
          self.layer.append((t[0], t[1] // 16, t[1] & 15, t[2]))
  
imports: import array
  import io
  import math
  import os
  import struct
  import subprocess
  import sys
  import tempfile
  import warnings
  from .None import Image, ImageFile, TiffImagePlugin
  from ._binary import i16be
  from ._binary import i32be
  from ._binary import o8
  from .JpegPresets import presets
label_desc: Use image node_id 4 for calling a global function with example usage: SOF(marker) without return types