code: def _extract_direct(self, *, stream):
          
  
          def normal_dct_rgb():
              # Normal DCTDecode RGB images have the default value of
              # /ColorTransform 1 and are actually in YUV. Such a file can be
              # saved as a standard JPEG. RGB JPEGs without YUV conversion can't
              # be saved as JPEGs, and are probably bugs. Some software in the
              # wild actually produces RGB JPEGs in PDFs (probably a bug).
              DEFAULT_CT_RGB = 1
              ct = self.filter_decodeparms[0][1].get('/ColorTransform', DEFAULT_CT_RGB)
              return self.mode == 'RGB' and ct == DEFAULT_CT_RGB
  
          def normal_dct_cmyk():
              # Normal DCTDecode CMYKs have /ColorTransform 0 and can be saved.
              # There is a YUVK colorspace but CMYK JPEGs don't generally use it
              DEFAULT_CT_CMYK = 0
              ct = self.filter_decodeparms[0][1].get('/ColorTransform', DEFAULT_CT_CMYK)
              return self.mode == 'CMYK' and ct == DEFAULT_CT_CMYK
  
          if self.filters == ['/CCITTFaxDecode']:
              data = self.obj.read_raw_bytes()
              stream.write(self._generate_ccitt_header(data))
              stream.write(data)
              return '.tif'
          elif self.filters == ['/DCTDecode'] and (
              self.mode == 'L' or normal_dct_rgb() or normal_dct_cmyk()
          ):
              buffer = self.obj.get_raw_stream_buffer()
              stream.write(buffer)
              return '.jpg'
  
          raise UnsupportedImageTypeError()
docs: Attempt to extract the image directly to a usable image file
  
          If there is no way to extract the image without decompressing or
          transcoding then raise an exception. The type and format of image
          generated will vary.
  
          Args:
              stream: Writable stream to write data to