code: def generate_source_image(source_file, processor_options, generators=None,
                            fail_silently=True):
      
      processor_options = ThumbnailOptions(processor_options)
      # Keep record of whether the source file was originally closed. Not all
      # file-like objects provide this attribute, so just fall back to False.
      was_closed = getattr(source_file, 'closed', False)
      if generators is None:
          generators = [
              utils.dynamic_import(name)
              for name in settings.THUMBNAIL_SOURCE_GENERATORS]
      exceptions = []
      try:
          for generator in generators:
              source = source_file
              # First try to open the file.
              try:
                  source.open()
              except Exception:
                  # If that failed, maybe the file-like object doesn't support
                  # reopening so just try seeking back to the start of the file.
                  try:
                      source.seek(0)
                  except Exception:
                      source = None
              try:
                  image = generator(source, **processor_options)
              except Exception as e:
                  if not fail_silently:
                      if len(generators) == 1:
                          raise
                      exceptions.append(e)
                  image = None
              if image:
                  return image
      finally:
          # Attempt to close the file if it was closed originally (but fail
          # silently).
          if was_closed:
              try:
                  source_file.close()
              except Exception:
                  pass
      if exceptions and not fail_silently:
          raise NoSourceGenerator(*exceptions)
docs: Processes a source ``File`` through a series of source generators, stopping
      once a generator returns an image.
  
      The return value is this image instance or ``None`` if no generators
      return an image.
  
      If the source file cannot be opened, it will be set to ``None`` and still
      passed to the generators.