docs: def _optimize_image_external(filename, func, image_format, new_ext):
      """Optimize the file with the external function."""
      new_filename = filename + TMP_SUFFIX + new_ext
      new_filename = os.path.normpath(new_filename)
      shutil.copy2(filename, new_filename)
  
      ext_args = ExtArgs(filename, new_filename)
      new_image_format = func(ext_args)
  
      report_stats = files.cleanup_after_optimize(filename, new_filename,
                                                  image_format,
                                                  new_image_format)
      percent = stats.new_percent_saved(report_stats)
      if percent != 0:
          report = '{}: {}'.format(func.__name__, percent)
      else:
          report = ''
      report_stats.report_list.append(report)
  
      return report_stats