code: def write(self, image, options, thumbnail):
          
          if options['format'] == 'JPEG' and options.get(
                  'progressive', settings.THUMBNAIL_PROGRESSIVE):
              image['options']['interlace'] = 'line'
  
          image['options']['quality'] = options['quality']
  
          args = settings.THUMBNAIL_CONVERT.split(' ')
          args.append(image['source'] + '[0]')
  
          for k in image['options']:
              v = image['options'][k]
              args.append('-%s' % k)
              if v is not None:
                  args.append('%s' % v)
  
          flatten = "on"
          if 'flatten' in options:
              flatten = options['flatten']
  
          if settings.THUMBNAIL_FLATTEN and not flatten == "off":
              args.append('-flatten')
  
          suffix = '.%s' % EXTENSIONS[options['format']]
  
          with NamedTemporaryFile(suffix=suffix, mode='rb') as fp:
              args.append(fp.name)
              args = map(smart_str, args)
              p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
              returncode = p.wait()
              out, err = p.communicate()
  
              if returncode:
                  raise EngineError(
                      "The command %r exited with a non-zero exit code and printed this to stderr: %s"
                      % (args, err)
                  )
              elif err:
                  logger.error("Captured stderr: %s", err)
  
              thumbnail.write(fp.read())
docs: Writes the thumbnail image