code: def extract_to(self, *, stream=None, fileprefix=''):
          
  
          if bool(stream) == bool(fileprefix):
              raise ValueError("Cannot set both stream and fileprefix")
          if stream:
              return self._extract_to_stream(stream=stream)
  
          bio = BytesIO()
          extension = self._extract_to_stream(stream=bio)
          bio.seek(0)
          filepath = Path(Path(fileprefix).name + extension)
          with filepath.open('wb') as target:
              copyfileobj(bio, target)
          return str(filepath)
docs: Attempt to extract the image directly to a usable image file
  
          If possible, the compressed data is extracted and inserted into
          a compressed image file format without transcoding the compressed
          content. If this is not possible, the data will be decompressed
          and extracted to an appropriate format.
  
          Because it is not known until attempted what image format will be
          extracted, users should not assume what format they are getting back.
          When saving the image to a file, use a temporary filename, and then
          rename the file to its final name based on the returned file extension.
  
          Examples:
  
              >>> im.extract_to(stream=bytes_io)
              '.png'
  
              >>> im.extract_to(fileprefix='/tmp/image00')
              '/tmp/image00.jpg'
  
          Args:
              stream: Writable stream to write data to.
              fileprefix (str or Path): The path to write the extracted image to,
                  without the file extension.
  
          Returns:
              str: If *fileprefix* was provided, then the fileprefix with the
                  appropriate extension. If no *fileprefix*, then an extension
                  indicating the file type.