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 = i8(s[0])
      if self.bits != 8:
          raise SyntaxError("cannot handle %d-bit layers" % self.bits)
  
      self.layers = i8(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(
              "cannot handle %d-layer images" % self.layers
          )
  
      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 i8(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 = None
  
      for i in range(6, len(s), 3):
          t = s[i : i + 3]
          # 4-tuples: id, vsamp, hsamp, qtable
          self.layer.append(
              (t[0], i8(t[1]) // 16, i8(t[1]) & 15, i8(t[2]))
          )
  
imports: from __future__ import print_function
  import array
  import io
  import struct
  import warnings
  from .None import Image, ImageFile, TiffImagePlugin
  from ._binary import i8, i16be, i32be, o8
  from ._util import isStringType
  from .JpegPresets import presets
label_desc: Use image node_id 4 for calling a global function with example usage: SOF(marker) without return types